create a macro in sas -


i have report generated once year. each report has form of year inside name - report-2011.xls, report-2012.xls etc. each report contains following vars: id, sal=average monthly salary of year, gender (0=male, 1=female), married (0=not married, 1=married), need create macro calculates mean.std,min , max of salary, per year in accordance gender type , married type. in macro need include parameter relevant year. how refer each type separately in calculating these parameters? , how create separate parameter year var?

proc summary allows control ways want cross data.

%macro report(year);  proc import datafile="/path/to/report-&year..xls"     out= salary_data                                                                                                                              dbms=csv replace ;                                                                                                                          proc summary data = salary_data;     class married gender;     types married gender married*gender;     var sal;     output out = salary_results mean(sal) = mean_salary std(sal) = std_salary;  * print summary; proc print;   * delete data , summary after using them; proc delete data= salary_data salary_results; run;   %mend report; 

note proc summary produces other useful information can read here. can drop them if don't need them.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -