3月 252010
 


Sometimes it is very handy to have a macro variable contanining the variables names of the dataset. Here are the 2 different ways you can create a macro variable with list of variables names ... *Method1: Using Proc Contents and Proc SQL; proc contents data=sashelp.class out=class; run; proc sql noprint; select distinct(name) into:vars separated by " " from class; quit; %put &vars; *Method2: Using SASHELP tables and Proc SQL; data class; set sashelp.vcolumn(where=(libname="SASHELP" and memname="CLASS")); keep name; run; proc sql noprint; select distinct(name) into:vars separated by " " from class; quit; %put &vars;

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]
 Posted by at 9:49 上午
3月 252010
 


Sometimes it is very handy to have a macro variable contanining the variables names of the dataset. Here are the 2 different ways you can create a macro variable with list of variables names ... *Method1: Using Proc Contents and Proc SQL; proc contents data=sashelp.class out=class; run; proc sql noprint; select distinct(name) into:vars separated by " " from class; quit; %put &vars; *Method2: Using SASHELP tables and Proc SQL; data class; set sashelp.vcolumn(where=(libname="SASHELP" and memname="CLASS")); keep name; run; proc sql noprint; select distinct(name) into:vars separated by " " from class; quit; %put &vars;

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]
 Posted by at 9:49 上午
3月 232010
 
Every person in my department at SAS (User and Customer Marketing) is involved in supporting SAS Global Forum in one way or another. One of the major roles is to coordinate the SAS Demo Area. I recently had a chat with my co-worker Katie Strange, who is responsible for teaming with many others at SAS to make the Demo Area a reality.

1. When did you start planning the SAS Demo Area?
From mid-October to April is the time frame when the planning is the most intense. However, like many events, the demo area planning is an on-going processes and overlaps with the current and future show.

2. How long does it take to build the SAS Demo Area, once you get on-site?
It takes an abundance of people with an incredible amount of talent to take the demo area from concept to reality. Our core team is a group of exceptional folks in Art and Scenic Operations, IT, Materials Management, Corporate Creative, Marketing and R&D. The demo area is a magnificent example of how SAS employees work in a cross-functional environment for the betterment of SAS and our customers.

But to answer your question - we start with a blank canvas at 6 am on Thursday morning, April 8, and are slated for the demo area to be set by 1 pm on Sunday, April 11. We open for attendees at 10 am on Monday, April 12.

3. What have you learned over the past few years that might surprise people?
I have learned that our show floor is a living, breathing and ever-evolving creature. Although the demo area takes many shapes and forms over the years, the one constant is the fact that this is an area that brings together a vast array of people because of their passion for knowledge and SAS. To me, that’s a beautiful thing.

4. Who can we find in the SAS Demo Area?
You will always be able to find SAS experts, such as SAS developers who are available and eager to help in any way they can. And at the Monday Night SAS Mixer you can find a few surprises, such as a lipsologist, a masseuse and much more! Don’t miss it!

5. What’s always been popular, and what’s new this year?
Perennial favorites are the Demo Alley where customers can have one on one time with SAS developers, the books store in the Publications area, the SAS Education Center and the SGF postcards booth.

There are also several exciting, new things this year such as the Innovations Wall and the Twitter Wall. The Innovations Wall is a place where attendees can view some of SAS’ innovations and contribute their own stories about how they have used SAS in innovative ways. The Twitter Wall will be displayed above the entrance to the Demo Area and will stream live tweets about the conference. There will also be a social networking booth near the Twitter Wall that is a resource for individuals who want to make the transition into the social networking realm but haven’t quite taken that leap yet.

3月 222010
 
Contributed by Memsy Price, Manager, Online Customer Support, SAS

Spring has sprung in North Carolina and here on the support.sas.com team our thoughts have turned towards sunny afternoons, daffodils, and — oh my goodness! — all we have to do before SAS Global Forum.

The 2010 SAS Global Forum, in Seattle, will be only my second, which makes me whatever ranks below novice in SAS years. What I lack in years of attendance, though, I’m making up for in enthusiasm. My first SAS Global Forum was a terrific experience — I got to meet and talk with so many users, and to hear directly from you what you like and, almost more importantly, what you don’t like about support.sas.com.

I hope this year will bring more of the same. Three of us from the support site team — Renee Harper, Paul Tidball, and myself — will be in Seattle working a station in the demo room. We’ll be showing the new SASware Ballot application, the recently-unveiled Advanced Search feature, updates to the product pages, some tips and tricks for navigating and searching the site, and some pointers about how to get the most out of the discussion forums.

Mostly, though, we hope you stop by to share your ideas with us. We talk to you every day in the forums, on e-mail, and through this blog, but we welcome the chance to talk face-to-face.

In addition to our spot in the demo room, the support.sas.com extended team has a couple of other activities planned. We hope that you can find time to add these to your conference agenda.
Continue reading "The support.sas.com team wants to meet YOU at SAS Global Forum 2010"
3月 222010
 
原文載點:http://analytics.ncsu.edu/sesug/2009/PO008.Welch.pdf

在作2乘2的卡方分析時,我們通常會看每一格裡面的樣本期望值是不是大於五,如果不大於五的比例超過一半的話,便需要使用 Fisher's exact test 的結果來取代原本的卡方分析結果。但這種判斷方法,在2乘2乘H的表格下並不適用。Mantel 和 Fleisś 在 1980 年代發明了一種判斷方法來專門處理這種情況,不過這個方法並沒有內建在 SAS 現存的程序內,因此 Brandon Welch, Jane Eslinger 和 Rob Woolson 在 2009 年的 SESUG 發表了一篇技術文件,提供一個簡便的 macro 供使用者使用。

有關 Mantel-Fleisś criterion 的理論,可詳見原文。以下就直接切入這個 macro 的使用方法:
%MantelFleiss(In,Strat,Var1,Var2,Count)

這個名為 MantelFleiss 的 macro 只有五個參數,定義如下:
  • In:資料集名稱
  • Strat: 層數,亦即2乘2表格的數量(H)
  • Var1:行變數
  • Var2:列變數
  • Count:此變數是加權變數(weight),是非必要的變數。如果省略的話,程式會自動定義為「1」。
原始碼如下:
%macro MantelFleiss(In,Strat,Var1,Var2,Count);

%*-----------------------------------------------------------;
%* &In - input data set ;
%* &Strat - stratification variable (e.g., site, race, etc.);
%* &Var1 - row variable ;
%* &Var2 - column variable ;
%* &Count - optional weight variable ;
%*-----------------------------------------------------------;

%*reset output data sets;
PROC DATASETS nodetails nolist;
delete _counts _expect _mantel:;
RUN;
QUIT;

%*determine number of strata levels;
PROC SQL noprint;
select count(distinct &strat) into: stratflag from &In;
QUIT;
%put **Number of strata levels &stratflag;

%*get expected counts and totals in each partial table;
PROC FREQ data = &In;
tables &Strat*&Var1*&Var2 / expected outexpect out = _expect;
%if %nrbquote(&Count.) ne %then weight &Count.;;
ODS output CrossTabFreqs = _counts;
RUN;

%*get sum of expected cell counts in cell n11 in each partial table
(assign to macro var SUMEXP);
DATA _null_;
set _expect end = eof;
by &Strat;
retain sumexp 0;
if first.&Strat then do;
sumexp = sumexp + expected;
end;
if eof then call symput('sumexp',put(sumexp,8.4));
RUN;
%put Sum of expected values in cells nh11: sum(mh11) = %cmpres(&sumexp);

PROC SORT data = _counts;
by &Strat &Var1 &Var2;
RUN;


%*Subset to the needed totals output by PROC FREQ
number the &Strat, &Var1, and &Var2 for use below
0 - totals
1 - first &Strat/&Var1/&Var2
2 - second &Strat/&Var1/&Var2
...;

DATA _mantelf1;
%*only include marginal totals from ODS;
set _counts(where = (_type_ not in ('100' '111')));
by &Strat &Var1 &Var2;
retain &Strat._ 0 &Var1._ &Var2._;

%*reset for change in strata;
if first.&Strat then do;
&Var1._ = 0; &Var2._ = 0;
end;

%*get numeric version of strata variable;
if first.&Strat then &Strat._ = &Strat._ + 1;

%*define zero as total for any &Var1/&Var2;
if missing(&Var1) then &Var1._ = 0;
else &Var1._ + 1;

if missing(&Var2) then &Var2._ = 0;
else &Var2._ + 1;

keep &Strat._ &Var1._ &Var2._ &Strat. &Var1. &Var2. frequency;
RUN;

DATA _mantelf2;
set _mantelf1;
by &Strat._;

retain n11_ n1_1 n1_2;

if first.&Strat._ then do;
n11_ = 0;
n1_1 = 0;
n1_2 = 0;
end;

%*get each total;
if &Var1._ = 1 then n11_ = frequency; %*for row one in the hth strata;
if &Var2._ = 1 then n1_1 = frequency; %*for column one in the hth strata;
if &Var2._ = 2 then n1_2 = frequency; %*for column two in the hth strata;


%*define (nh11)L and (nh11)U for final computation;
max_ = max(0,n11_-n1_2);
min_ = min(n1_1,n11_);

if last.&Strat._;

RUN;

%*sum acoss min and max to get lower/upper bounds of criterion;
DATA _mantelf3(keep = mf_suml mf_sumu mflendpt mfrendpt mf_r);
set _mantelf2 end = eof;

retain mf_suml mf_sumu;

if _n_ = 1 then do;
mf_suml = 0; mf_sumu = 0;

end;

mf_suml = mf_suml + max_;
mf_sumu = mf_sumu + min_;

if eof then do;
mflendpt = &sumexp-mf_suml;
mfrendpt = mf_sumu-&sumexp;
mf_r = min(mflendpt,mfrendpt);

put "Sum of lower bound (sum[(nh11)L]) = " mf_suml;
put "Sum of upper bound (sum[(nh11)U]) = " mf_sumu;
put "Left end-point: sum[mh11] - sum[(nh11)L] = " mflendpt;
put "Right endpoint: sum[(nh11)U] - sum[mh11] = " mfrendpt;
put "Mantel-Fleiss R = min[" mflendpt "," mfrendpt "] = " mf_r;

if mf_r>5 then put "Mantel-Fleiss criterion satisfied (since R > 5)";
else put "Mantel-Fleiss criterion NOT satisfied (since R <= 5)";
output;
end;

label
mf_suml = "Summation of Maximum (sum[(nh11)L])"
mf_sumu = "Summation of Minumum (sum[(nh11)U])"
mflendpt = "Left End-Point: sum[mh11] - sum[(nh11)L]"
mfrendpt = "Right End-Point: sum[(nh11)U] - sum[mh11]"
mf_r = "R Value: min[sum[mh11] - sum[(nh11)L],sum[(nh11)U] - sum[mh11]]";
RUN;
%mend;


範例一:
資料檔:
PROC FORMAT;
value trtf
1 = 'TreatmentA'
2 = 'TreatmentB'
;

value sitef
1 = 'Arkansas'
2 = 'Indiana'
3 = 'Illinois'
;

value respf
1 = 'Present'
2 = 'Absent'
;
RUN;

DATA test;
do site = 1 to 3;
do treat = 1 to 2;
do resp = 1 to 2;
input counts @@;
output;
end;
end;
end;
label site = "Site" treat = "Treatment" resp = "Response";
format treat trtf. site sitef. resp respf.;
cards;
12 5 7 3
1 2 5 2
0 9 5 6
;
RUN;


上述程式在表格內呈現的結果如下:


接著執行 macro:
%MantelFleiss(test,site,treat,resp,counts) ;

要特別注意的一點是,這個 macro 的結果並不是呈現在 output 視窗裡面,而是直接呈現在 log 視窗裡面,所以送出這行程式碼後,便可以直接在 log 視窗上看到結果,如下所示:
Sum of expected values in cells nh11: sum(mh11) = 20.5130
Sum of lower bound (sum[(nh11)L]) = 9
Sum of upper bound (sum[(nh11)U]) = 25
Left end-point: sum[mh11] - sum[(nh11)L] = 11.513
Right endpoint: sum[(nh11)U] - sum[mh11] = 4.487
Mantel-Fleiss R = min[11.513 ,4.487 ] = 4.487
Mantel-Fleiss criterion NOT satisfied (since R <= 5)


原文作者很好心地幫使用者做出該資料是否有滿足 Mantel-Fleiss criterion 的判斷句,所以就不用管上面的數據所代表的意義了,但若在寫 paper 時,可能還是要把一些數據呈現出來,但其實這些數據並沒有解釋上的明顯意義。

這個例子並沒有滿足 Mantel-Fleiss criterion,也就是說我們得使用 Fisher's exact test 來取代原本的卡方檢定。

我們再來看另一個有滿足 Mantel-Fleiss criterion 的例子。

範例二:

我們直接來看資料的表格結構。

所有參數設定都和範例一同樣,只是數據改變而已。執行 macro 後的結果如下:
Sum of expected values in cells nh11: sum(mh11) = 19.3630
Sum of lower bound (sum[(nh11)L]) = 9
Sum of upper bound (sum[(nh11)U]) = 30
Left end-point: sum[mh11] - sum[(nh11)L] = 10.363
Right endpoint: sum[(nh11)U] - sum[mh11] = 10.637
Mantel-Fleiss R = min[10.363 ,10.637 ] = 10.363
Mantel-Fleiss criterion satisfied (since R > 5)


從最後一句話得知這份資料是有滿足 Mantel-Fleiss criterion 的,所以我們便可以直接使用卡方檢定的結果。

CONTACT INFORMATION
Brandon Welch
Rho®, Inc.
Statistical Programming
6330 Quadrangle Dr., Ste. 500
Chapel Hill, NC 27517
Email: Brandon_Welch@rhoworld.com
Phone: 919-595-6339
3月 222010
 
原文載點:http://analytics.ncsu.edu/sesug/2009/PO008.Welch.pdf

在作2乘2的卡方分析時,我們通常會看每一格裡面的樣本期望值是不是大於五,如果不大於五的比例超過一半的話,便需要使用 Fisher's exact test 的結果來取代原本的卡方分析結果。但這種判斷方法,在2乘2乘H的表格下並不適用。Mantel 和 Fleisś 在 1980 年代發明了一種判斷方法來專門處理這種情況,不過這個方法並沒有內建在 SAS 現存的程序內,因此 Brandon Welch, Jane Eslinger 和 Rob Woolson 在 2009 年的 SESUG 發表了一篇技術文件,提供一個簡便的 macro 供使用者使用。

有關 Mantel-Fleisś criterion 的理論,可詳見原文。以下就直接切入這個 macro 的使用方法:
%MantelFleiss(In,Strat,Var1,Var2,Count)

這個名為 MantelFleiss 的 macro 只有五個參數,定義如下:
  • In:資料集名稱
  • Strat: 層數,亦即2乘2表格的數量(H)
  • Var1:行變數
  • Var2:列變數
  • Count:此變數是加權變數(weight),是非必要的變數。如果省略的話,程式會自動定義為「1」。
原始碼如下:
%macro MantelFleiss(In,Strat,Var1,Var2,Count);

%*-----------------------------------------------------------;
%* &In - input data set ;
%* &Strat - stratification variable (e.g., site, race, etc.);
%* &Var1 - row variable ;
%* &Var2 - column variable ;
%* &Count - optional weight variable ;
%*-----------------------------------------------------------;

%*reset output data sets;
PROC DATASETS nodetails nolist;
delete _counts _expect _mantel:;
RUN;
QUIT;

%*determine number of strata levels;
PROC SQL noprint;
select count(distinct &strat) into: stratflag from &In;
QUIT;
%put **Number of strata levels &stratflag;

%*get expected counts and totals in each partial table;
PROC FREQ data = &In;
tables &Strat*&Var1*&Var2 / expected outexpect out = _expect;
%if %nrbquote(&Count.) ne %then weight &Count.;;
ODS output CrossTabFreqs = _counts;
RUN;

%*get sum of expected cell counts in cell n11 in each partial table
(assign to macro var SUMEXP);
DATA _null_;
set _expect end = eof;
by &Strat;
retain sumexp 0;
if first.&Strat then do;
sumexp = sumexp + expected;
end;
if eof then call symput('sumexp',put(sumexp,8.4));
RUN;
%put Sum of expected values in cells nh11: sum(mh11) = %cmpres(&sumexp);

PROC SORT data = _counts;
by &Strat &Var1 &Var2;
RUN;


%*Subset to the needed totals output by PROC FREQ
number the &Strat, &Var1, and &Var2 for use below
0 - totals
1 - first &Strat/&Var1/&Var2
2 - second &Strat/&Var1/&Var2
...;

DATA _mantelf1;
%*only include marginal totals from ODS;
set _counts(where = (_type_ not in ('100' '111')));
by &Strat &Var1 &Var2;
retain &Strat._ 0 &Var1._ &Var2._;

%*reset for change in strata;
if first.&Strat then do;
&Var1._ = 0; &Var2._ = 0;
end;

%*get numeric version of strata variable;
if first.&Strat then &Strat._ = &Strat._ + 1;

%*define zero as total for any &Var1/&Var2;
if missing(&Var1) then &Var1._ = 0;
else &Var1._ + 1;

if missing(&Var2) then &Var2._ = 0;
else &Var2._ + 1;

keep &Strat._ &Var1._ &Var2._ &Strat. &Var1. &Var2. frequency;
RUN;

DATA _mantelf2;
set _mantelf1;
by &Strat._;

retain n11_ n1_1 n1_2;

if first.&Strat._ then do;
n11_ = 0;
n1_1 = 0;
n1_2 = 0;
end;

%*get each total;
if &Var1._ = 1 then n11_ = frequency; %*for row one in the hth strata;
if &Var2._ = 1 then n1_1 = frequency; %*for column one in the hth strata;
if &Var2._ = 2 then n1_2 = frequency; %*for column two in the hth strata;


%*define (nh11)L and (nh11)U for final computation;
max_ = max(0,n11_-n1_2);
min_ = min(n1_1,n11_);

if last.&Strat._;

RUN;

%*sum acoss min and max to get lower/upper bounds of criterion;
DATA _mantelf3(keep = mf_suml mf_sumu mflendpt mfrendpt mf_r);
set _mantelf2 end = eof;

retain mf_suml mf_sumu;

if _n_ = 1 then do;
mf_suml = 0; mf_sumu = 0;

end;

mf_suml = mf_suml + max_;
mf_sumu = mf_sumu + min_;

if eof then do;
mflendpt = &sumexp-mf_suml;
mfrendpt = mf_sumu-&sumexp;
mf_r = min(mflendpt,mfrendpt);

put "Sum of lower bound (sum[(nh11)L]) = " mf_suml;
put "Sum of upper bound (sum[(nh11)U]) = " mf_sumu;
put "Left end-point: sum[mh11] - sum[(nh11)L] = " mflendpt;
put "Right endpoint: sum[(nh11)U] - sum[mh11] = " mfrendpt;
put "Mantel-Fleiss R = min[" mflendpt "," mfrendpt "] = " mf_r;

if mf_r>5 then put "Mantel-Fleiss criterion satisfied (since R > 5)";
else put "Mantel-Fleiss criterion NOT satisfied (since R <= 5)";
output;
end;

label
mf_suml = "Summation of Maximum (sum[(nh11)L])"
mf_sumu = "Summation of Minumum (sum[(nh11)U])"
mflendpt = "Left End-Point: sum[mh11] - sum[(nh11)L]"
mfrendpt = "Right End-Point: sum[(nh11)U] - sum[mh11]"
mf_r = "R Value: min[sum[mh11] - sum[(nh11)L],sum[(nh11)U] - sum[mh11]]";
RUN;
%mend;


範例一:
資料檔:
PROC FORMAT;
value trtf
1 = 'TreatmentA'
2 = 'TreatmentB'
;

value sitef
1 = 'Arkansas'
2 = 'Indiana'
3 = 'Illinois'
;

value respf
1 = 'Present'
2 = 'Absent'
;
RUN;

DATA test;
do site = 1 to 3;
do treat = 1 to 2;
do resp = 1 to 2;
input counts @@;
output;
end;
end;
end;
label site = "Site" treat = "Treatment" resp = "Response";
format treat trtf. site sitef. resp respf.;
cards;
12 5 7 3
1 2 5 2
0 9 5 6
;
RUN;


上述程式在表格內呈現的結果如下:


接著執行 macro:
%MantelFleiss(test,site,treat,resp,counts) ;

要特別注意的一點是,這個 macro 的結果並不是呈現在 output 視窗裡面,而是直接呈現在 log 視窗裡面,所以送出這行程式碼後,便可以直接在 log 視窗上看到結果,如下所示:
Sum of expected values in cells nh11: sum(mh11) = 20.5130
Sum of lower bound (sum[(nh11)L]) = 9
Sum of upper bound (sum[(nh11)U]) = 25
Left end-point: sum[mh11] - sum[(nh11)L] = 11.513
Right endpoint: sum[(nh11)U] - sum[mh11] = 4.487
Mantel-Fleiss R = min[11.513 ,4.487 ] = 4.487
Mantel-Fleiss criterion NOT satisfied (since R <= 5)


原文作者很好心地幫使用者做出該資料是否有滿足 Mantel-Fleiss criterion 的判斷句,所以就不用管上面的數據所代表的意義了,但若在寫 paper 時,可能還是要把一些數據呈現出來,但其實這些數據並沒有解釋上的明顯意義。

這個例子並沒有滿足 Mantel-Fleiss criterion,也就是說我們得使用 Fisher's exact test 來取代原本的卡方檢定。

我們再來看另一個有滿足 Mantel-Fleiss criterion 的例子。

範例二:

我們直接來看資料的表格結構。

所有參數設定都和範例一同樣,只是數據改變而已。執行 macro 後的結果如下:
Sum of expected values in cells nh11: sum(mh11) = 19.3630
Sum of lower bound (sum[(nh11)L]) = 9
Sum of upper bound (sum[(nh11)U]) = 30
Left end-point: sum[mh11] - sum[(nh11)L] = 10.363
Right endpoint: sum[(nh11)U] - sum[mh11] = 10.637
Mantel-Fleiss R = min[10.363 ,10.637 ] = 10.363
Mantel-Fleiss criterion satisfied (since R > 5)


從最後一句話得知這份資料是有滿足 Mantel-Fleiss criterion 的,所以我們便可以直接使用卡方檢定的結果。

CONTACT INFORMATION
Brandon Welch
Rho®, Inc.
Statistical Programming
6330 Quadrangle Dr., Ste. 500
Chapel Hill, NC 27517
Email: Brandon_Welch@rhoworld.com
Phone: 919-595-6339
 Posted by at 9:32 上午
3月 182010
 
data driver;
  
infile datalines truncover;
  
input string $ 1 - 100;
datalines;
woe
fmt
;
run;

%macro grep(path = , ext = , driver = , str = );
*************************************************;
* THIS MACRO IS TO DO A STRING SEARCH FUNCTION  *;
* SIMILAR TO GREP IN UNIX                       *;
* --------------------------------------------- *;
* PARAMETERS:                                   *;
*  path  : the path to be searched              *;
*  ext   : file extension to be searched        *;
*  driver: the driver table containing strings  *;
*          to search for                        *;
*  str   : field name containing strings in the *;
*          driver table                         *;
* --------------------------------------------- *;
* OUTPUT: 1 txt file per string searched        *;
* --------------------------------------------- *;
* LIMITATION: only works for UNIX               *;
*************************************************;

data _null_;
  
set &driver;
  i +
1;
  
index = put(i, z3.);
  cmd   =
"find %trim(&path) -name '"||"%trim(&ext)"||"' | xargs grep -i '"
          ||strip(
&str)||"' > "||index||'_'
          ||
translate(strip(&str), '_', ' ')||".txt";
  
put cmd;
  
call system(cmd);
run;

%mend grep;

%grep(path = /yourpath/, ext = *.
log, driver = driver, str = string);
 Posted by at 10:03 上午  Tagged with:
3月 162010
 
1. GTL can easily put multiple images in a single panel;
2. GTL can also apply multiple curves in a single column image;


proc template;
define statgraph graph.one;
begingraph;
entrytitle "Horsepower Profile in a 2X1 panel";
layout lattice / rows=1 columns=2 rowweights=(.5 .5) ;
*****FIRST HISTOGRAM + DENSITYPLOT;
layout overlay;
histogram horsepower;
densityplot horsepower;
endlayout;
*****SECOND SCATTERPLOT + REGRESSIONPLOT;
layout overlay / yaxisopts=(griddisplay=on);
scatterplot x=horsepower y=mpg_city;
regressionplot x=horsepower y=mpg_city / degree=2;
endlayout;
endlayout;
endgraph;
end;
run;

*****ODS GRAPHICS CAN SPECIFY THE SIZE OF OUTPUT IMAGE;
ods graphics on/width=25cm height=15cm antialiasmax=10000 imagefmt=PNG;
proc sgrender data=sashelp.cars
template=graph.one;
run;



Reference: SAS: Graph Template Language Reference
3月 162010
 
1. Data by state is obtained manually from indeed.com (14 days range @15Mar2010);
2. Conclusion: SAS programmer opens most occur on the east and west coast


data sites;
length stcode $ 2;
input stcode $ region sites;
state=stfips(stcode);
datalines;

AR 6 1
AK 10 0
AL 4 1
AZ 9 36
CA 9 146
CO 8 10
CT 1 35
DE 3 46
FL 4 36
GA 4 36
HI 9 3
IA 7 4
ID 10 0
IL 5 68
IN 5 13
KS 7 15
KY 4 5
LA 6 0
MA 1 63
MD 3 64
ME 1 3
MI 5 19
MN 5 42
MO 7 9
MS 4 0
MT 8 0
NC 4 99
ND 8 0
NE 7 0
NH 1 0
NJ 2 129
NM 6 2
NV 9 1
NY 2 73
OH 5 27
OK 6 0
OR 10 0
PA 3 85
RI 1 5
SC 4 1
SD 8 0
TN 4 6
TX 6 42
UT 8 8
VA 3 88
VT 1 0
WA 10 16
WI 5 14
WV 3 1
WY 8 0

;

title1 'SAS programmer openning by states';
footnote1 j=r 'From Indeed 15Mar2010';
****CHOOSE CHOROPLETH LAYOUT;
proc gmap map=maps.us data=sites;
id state;
choro sites / coutline=gray;
run;
quit;



Reference: SAS online sample
3月 152010
 


1. Import a CSV file automatically from YAHOO by Infile url;

2. Plot a time series about a stock pricing;


*****INPUT MICROSOFT DATA FROM YAHOO/finance;
filename dataurl url "http://ichart.finance.yahoo.com/table.csv?s=MSFT" debug;
data mydata;
*****DECLARE THE VARIABLES INFILED;
format date year4.;
format open high low close adj_close dollar12.0;
format volume comma12.0;
*****FOR CSV FILE;
infile dataurl dlm=',' firstobs=2;
input date yymmdd10. open high low close volume adj_close;
run;
*****CHOOSE A TIME RANGE;
data mydata;
set mydata (where=(date>='01jan1995'd and date<='01mar2011'd)); run; goptions ftitle="arial/bold" ftext="arial" htitle=13pt htext=10pt device=png xpixels=1200 ypixels=460; *****SPECIFY THE HORIZONTAL AXIS; axis1 label=none order=('01jan1995'd to '01mar2011'd by year) minor=none offset=(.1,.1); *****SPECIFY THE VERTICAL AXIS; axis2 label=(j=c 'Microsoft (MSFT)' j=c 'closing price') style=0 major=(number=5) minor=none offset=(0,0); proc gplot data=mydata; title 'Microsoft share closing price'; *****DO TWICE TO STRENTHEN THE CURVE; plot adj_close*date=1 adj_close*date=1/ overlay vzero areas=1 haxis=axis1 vaxis=axis2 noframe autohref chref=grayda autovref cvref=grayda frontref; run;


Reference: SAS online sample