8月 282008

Transcoding failure.STP: A failure occurred in execution set up in context.

找到storedprocess WEB所在目录,更改如下文件:



 Posted by at 7:18 上午
8月 272008
Whew! I've been speeding around information stops all over the Web. That's quite a workout. As alluded to in my last post, you can find really useful information in some unlikely places. Given that I challenged you to broaden your Internet stops, I've been trying to do the same. Because time is limited, accepting that challenge for myself meant that I ignored my usual stomping grounds. Feeling traitorous, I returned to them this morning and right away found a gem to share with you. I found this gem on my way through the SAS discussion forums.

Cynthia@sas responds to a poster in the SAS Procedures forum who asked "Is there a way to count the frequency of strings within a character variable?" Cynthia provides a short SAS program that performs a frequency count of the words in the first chapter of Melville's Moby Dick. In her post, she writes:
Interestingly enough, after you eliminate all the articles and prepositions and pronouns, the most frequently used word in the first chapter of Moby Dick is 'sea' (13 times) followed by 'water' (8 times). The words 'ship', 'soul', 'man' and 'whale' each occur 3 times. Anyway, the relevant part of that program is shown below -- I had to get rid of a stray '?' in the chapter, which is why the compress is in the code. Also, I turned everything to lower case, so 'The' and 'the' would get counted the same when I did a frequency on the WORD variable.

See the post to get the code. Anybody want to count the words in the speeches given at the two political conventions?
8月 242008

ODS 系統在 SAS V9.1 版中已經逐漸發揮他的威力,到了 V9.2 版後更是往上提升了一個階層。不過很多人以為用用 ODS 把圖或報表直接輸出就已經是最方便的,殊不知他可以結合最簡單的 PROC PRINT 程序將輸出結果強化。這一篇在 NESUG 2007 發表的技術文件詳細記載了如何讓 ODS 搭配 PROC PRINT 來產生更美觀的報表,也同時揭露了一些在 SAS 手冊裡都沒有介紹的指令。

簡單來講,如果要用 PROC PRINT 程序加上 ODS 來列印報表,在完全沒有額外設定,只使用預設值的情況下,語法大概就諸如此款:

你拍攝的 2008-08-22_1738。

你拍攝的 2008-08-22_1734。

如果你覺得上面這種呈現方式有點像是墓碑上刻出來的文字,而想要換成別的樣式或顏色,那麼就得靠 PROC PRINT 程序手冊裡面都很少提到(至少 SAS online documentation 沒有寫)的 style option!

style option 基本的撰寫格式如下:
你拍攝的 2008-08-22_1738。

你拍攝的 2008-08-22_1755。

利用四個 style 指令將 Obs 標題顏色、表格內資料背景顏色、Obs 列顏色以及底部 total 底色一次進行修改。

接下來又一步一步來介紹不同 style 指令的用法。

1. 更改標題列顏色

你拍攝的 2008-08-23_1621。

你拍攝的 2008-08-23_1623。

其中,黃色標記處 style(header)={background=yellow}; 即是讓標題列變成黃色的關鍵。

2. 更改總和列顏色和字型和大小

PROC PRINT 裡面有個 SUM statement 可以計算每個欄位的總和,如想要更改此處的背景顏色、字型樣式和字型大小,如下圖所示:
你拍攝的 2008-08-23_1626。

你拍攝的 2008-08-23_1630。

黃色標明處 style (grandtotal)={background=grayee font=(Arial) font_size=6}; 即是更改由橘色標明處 SUM statement 所算出來的兩個總和欄位的背景顏色(grayee)、字型(Arial)和字型大小(font_size)。如果沒有 SUM statement,則黃色標明處的語法將不會有任何作用。

3. 更改表格資料欄背景顏色

你拍攝的 2008-08-23_1637。

你拍攝的 2008-08-23_1652。

黃色標明處 style(data)={background=grayee} 即是用來設定資料欄位背景顏色。附帶一提,標題列會自動斷成兩行是利用紅色標明處的 split='*' 進行設定,然後在橘色標明處 label statement 裡面將標題要斷行的地方打上 * 即可。

4. 更改分類總和欄位背景顏色

如果有使用 by statement 來計算不同分類欄位的總和,則其背景顏色也可以修改,如下圖所示:
你拍攝的 2008-08-23_1657。

你拍攝的 2008-08-23_1659。
你拍攝的 2008-08-23_1701。

此程式由於有使用 by origcity; 和 sum statement 來計算每個程式 sales2005 和 sales2006 的總和,所以要修改分類總和欄位的背景顏色,就得用黃色標明處的 style(total)={background=light green}; 來設定。

5. 更改特定欄位字體顏色

你拍攝的 2008-08-23_1704。

你拍攝的 2008-08-23_1707。
你拍攝的 2008-08-23_1706。

黃色標明處的 var month 後面加上 /style={foreground=red}; 就可以更改 month 這個欄位字型顏色。此外,一開頭的 SAS logo 是用 title3 後面的 "^S=preimage='c:\ben\qp\SAS_logo.bmp'}" 所貼上。

總結:作者有坦承這篇文件沒有把 22 個 trick 都用上,不過會在 conference 裡面說明。不過由於沒有她在會議裡面的任何影音檔,所以無法得知其他沒有在文件裡面的小技巧是什麼。但上述這些語法已經足夠讓表格變的更漂亮,因此有興趣的人可以玩玩不同組合最出現什麼情況。

Your comments and questions are valued and encouraged. Contact the author at:
Ben Cochran
The Bedford Group
Raleigh, NC 27607
Office: 919.831.1191
Fax: 919.831.1191
Email: bedfordgroup@nc.rr.com
Web: www.bedford-group.com
 Posted by at 4:13 上午
8月 202008
As August draws to a close and school systems all over the country are calling students back to their desks, I can't help but daydream about lavish vacation spots with warm breezes and cool blue water. But, this post isn't about vacationing. It is about finding information in out-of-the-way places. These sites aren't hidden or hard to find, they just exist on a different path than you usually take to your content. I'd like to introduce you to just a few things I found in places that I recently discovered.

Discovery 1
This is a tip from Kirk Paul Lafler that was published in the SESUG spring 2008 e-Newsletter.
Title:    PROC SQL Join Algorithms and the _METHOD Option


Read the tip to find out what this code can be used for.

Discovery 2
Here's a quick tip from the SAS UK office that appeared in their April In The Know e-Newsletter.
Question:    Is there a way to check the syntax of a step prior to executing the step?
Answer:    Yes, use the option 'Cancel' on the 'Run' statement. The CANCEL option terminates the step without executing it and prints a warning message that the step was not executed at the user's request.
Read the tip for example code.

Discovery 3
One last tip for you from the SAS Programmers group on Facebook. This tip was posted by Elinor Jane Leland Zenta, who wrote:
In the SAS window click tools => options => keys
In the F12 spot (which should be empty) type in
When you run your programs press F12 which will clear your log and output windows and submit your program.

Share your discoveries
Do you visit a location that others may not know about? If so, take a minute to share the location with the Support News blog readers by posting a comment below. Alison Bolen shared several lists of Web addresses that might be of interest to SAS professionals. You can view her list of Online communities for SAS users and SAS professionals in the sascom voices blog.
8月 202008

居然提供了一个Learning to Use SAS 这个帮助,很完善得例子,把SAS得每个模块都讲了,非常多,并且有详细得例子,例子看起来也特别简单易懂

 /*          S A S   S A M P

 Posted by at 7:19 上午
8月 202008

ods rtf file='c:\sample.rtf' bodytitle;
title 'My Sample Title';
footnote 'My Sample Footnote';
proc report data=sashelp.class nowd;
column age height weight;
define age / group;
define height / mean f=8.;
define weight / mean f=8.;
ods rtf close;


 Posted by at 6:42 上午
8月 152008

由於最近在工作上太多人問到這個問題,所以我特別找出這一篇文章來說明。在 SAS 裡面,要在每筆資料後面加上一個特定值,依據資料排列格式的不同,有許多種作法。有得很簡單,只需要在 data step 加上一行即可,有得很複雜,得動用到 merge statement 或 proc sql 才能解決。這一篇在 NESUG 2007 年發表的技術文件列出了一些解法可供參考。

data temp;
input Obs ID EARNHR @@;
1 1 .
2 2 5.75
3 3 5.75
4 4 6.30
5 5 6.75
6 6 8.00
7 7 8.25
8 8 9.60
9 9 10.05
10 10 12.80

如果打算算出 EARNHR 的中間值,然後讓他變成一個獨立的變數放在原資料 temp 的最後面。最常使用的方法是先使用 PROC MEANS 把中間值的結果另存到新的資料檔裡面:
proc means data = temp noprint ;
var EARNHR ;
output out = add (drop = _TYPE_ _FREQ_) median(EARNHR) = MEDIANEARNHR;
run ;

然後再用 merge 的方法放回原資料檔:
data temp3 ;
set temp ;
if _N_ = 1 then set add ;
run ;

接下來要教兩個進階用法。由於第一個方法會生出一個無用的資料檔 MEDIANEARNHR,雖然他只是放在暫存檔,關掉 SAS 後就會消失。但使用 PROC SQL 就根本連這個檔都不會產生。方法如下:
proc sql ;
select mean(EARNHR) as AVGEARNHR format = 8.2 into :MEANEARNHR
from temp ;

data temp ;
set temp ;
run ;

本例改成放 EARNHR 的平均值 MEANEARNHR。先用 PROC SQL 把 AVEARNHR 算出來,放進一個叫做 MEANEARNHR 的巨集變數裡面,然後在把他命名成mean放進原來的資料內。這還有很多其他的用途。比方說如果想要挑出 EARNHR 小於平均值的樣本,則可以用這個 data step 來挑出:
data temp2 ;
set temp ;
run ;

1 2 5.75
2 3 5.75
3 4 6.30
4 5 6.75
5 6 8.00

第三種方法則是用 SYMPUT 函式來定義巨集變數。此例,先用 PROC MEANS 去計算 EARNHR 的中間值,並存在 add2 裡面。
proc means data = temp noprint ;
var EARNHR ;
output out = add2 (drop=_TYPE_ _FREQ_) median(EARNHR) = MEDIANEARNHR;
run ;

然後開一個虛無的資料集「_null_」(這個資料連在work library都不會出現),然後把 add2 裡面的中間值變數名稱用 SYMPUT 定義成巨集變數。
data _null_ ;
set add2 ;
call symputx ('MDNEARNHR', MEDIANEARNHR) ;
run ;

最後就可以利用這個巨集變數在新的 data step 裡面做很多動作。無論是新增變數還是去挑資料都相當容易。
data temp;
set temp ;
where EARNHR ge 0 and EARNHR lt &MDNEARNHR ;
run ;

個人傾向使用 PROC SQL 是因為他能夠減少無謂的資料檔輸出,只是需要相當熟悉他的語法才能夠用上手。

Your comments and questions are valued and encouraged. Contact the author at:
Anne W. Warren
16 East 34th Street, 19th floor
New York, NY 10016
Work Phone: 212.340.8661
Fax: 212.684.0832
Email: anne.warren@mdrc.org
Web: www.mdrc.org
 Posted by at 4:33 上午
8月 052008
That's a fancy way of saying that we are adding a few more RSS feeds for support.sas.com visitors. Feeds are an efficient and easy way to get information about updates made to the SAS Support Web site. Feeds let you quickly stay current on updated content. I believe that if you scan the contents of the feeds every now and then, it will help you to locate information more quickly when you really need it.

How can that be? Well, it is just a theory, so I'd love to hear what you all think. My theory is that my brain holds on to more information than I can ever retrieve. (And it seems that the older I get, the harder it gets to retrieve information when I need it.) But, when I start to search for something -- either on a Web site or in a department store -- I am encouraged to keep looking if I know that I have seen the item I need. I often find that some snippet of the memory will return just in time to help me locate exactly the thing for which I am hunting. Well, it is just a theory, so I'd love to hear what you think.

I think that content notification (RSS in this case) can serve this purpose. Maybe you see a sample that looks interesting, so you read it on the spot. But what if you see information about a problem that you haven't encountered yet. Then weeks later, boom, you hit the same snag. Maybe you remember seeing it in the feed. Maybe you even remember part of the title, which will make your Web search much more successful.

Give the feeds a try and let me know if my theory is right or wrong.
Continue reading "New Syndicated Content"
8月 032008


 Posted by at 3:25 上午
8月 012008
Maybe the question should be "have you noticed the toolbar at the top of every support.sas.com page?" The big yellow arrow is pointing to the toolbar in the image below.

image of toolbar in the header

When you select the Print link, we strip all of the outer edges from the page (top and left navigation, footer and the right informational column if it exists). Your printer window is displayed and the page is sent to your designated printer. This works great for Samples & SAS Notes because we also concatenate the content from the various tabs into one printout!

While I'm talking about the toolbar, I should mention the other two features. The e-mail link will open a new message and will pre-fill the body of the message with the page title and the URL of the page you are viewing.

The bookmark feature opens the browser window that enables you to add a favorite link. When we designed the toolbar, several people wondered about the usefulness of this feature. What do you think? Are shortcut links like this nice to have?

Keep an eye on the toolbar. New features may appear there soon. What feature would you like to see as a toolbar item?