Thursday, May 18, 2017

SAS: PROC EXPAND CONVERT TRANSFORMOUT

Sample program without BY:



data testin;
input x @@;
datalines;
2 3 5 7 11 13 17 19 23
;
run;

proc expand data=testin out=testout;
* convert works for numeric variables only;
* automatically adds TIME variable;
* many functions available: check the documentation;
convert x = x_lead_2   / transformout=(lead 2);
convert x = x_lag3     / transformout=(lag  3);
convert x = x_plus_4   / transformout=(+ 4);
convert x = x_times_5  / transformout=(* 5);
run;






Sample program with BY:




data testin;
input group x @@;
datalines;
1 2 1 3 1 5 1 7 1 11 1 13 1 17 1 19 1 23
2 2 2 4 2 6 2 8 2 10 2 12 2 14 2 16 2 18
;
run;

proc expand data=testin out=testout;
* convert works for numeric variables only;
* automatically adds TIME variable;
* many functions available: check the documentation;
by group;
convert x = x_lead_2   / transformout=(lead 2);
convert x = x_lag3     / transformout=(lag  3);
convert x = x_plus_4   / transformout=(+ 4);
convert x = x_times_5  / transformout=(* 5);
run;





No comments:

Post a Comment