Showing posts with label format. Show all posts
Showing posts with label format. Show all posts

Wednesday, May 30, 2007

code for transforming data from multivariate format to the univariate format

data data;
infile 'c:\myfiles\testfile.dat';
input id y0 y1 y2 y3;
y=y0 trt=0; output;
y=y1 trt=1; output;
y=y2 trt=2; output;
drop y0-y2;
run;

Tuesday, February 13, 2007

quartiles (or x-tiles) for the lazy

data composite;
set data.composite;
proc rank groups=4 out=ranked;
var srcalc srprot sriron srmagnes srphos srzinc srvitc srvitd packyrs bmi;
ranks rank_srcalc rank_srprot rank_sriron rank_srmagnes rank_srphos rank_srzinc rank_srvitc rank_srvitd rank_packyrs rank_bmi;
run;

Sunday, February 11, 2007

create a categorical variable in one fell swoop

categorize a variable with "lazy elegance"

if age ne . then agecat= int(iage/5-1);

transpose data

Transpose your data from the so-called "long format" to the ever popular and
occassionally useful "wide format"



proc transpose data=long2 out=widef prefix=faminc;
by famid;
id year;
var faminc;
run;

proc transpose data=long2 out=wides prefix=spend;
by famid;
id year;
var spend;
run;

data wide2;
merge widef(drop=_name_) wides(drop=_name_);
by famid;
run;