data have;
input start_dt mmddyy10. calls 3.;
datalines;
10/26/2015 10
11/02/2015 12
11/09/2015 10
11/16/2015 8
;
proc sort data=have;
by start_dt;
run;
proc transpose data =have out=want (drop=_name_);
id start_dt;
var Calls;
run;
It gives me output as below:
_10_26_2015 _11_02_2015 _11_09_2015 _11_16_2015
10 12 10 8
But I want the Output as follows:
10/26/2015 11/02/2015 11/09/2015 11/16/2015
10 12 10 8
After transposed, date became variable name, in SAS, variable name is not allowed with digit at the first letter, and '/' is not allowed, but '_ ' is Ok. You could use label in transpose, such as:
proc transpose data =have out=want (drop=_name_);
id start_dt;
var Calls;
label _10_26_2015='10/26/2015';
run;
Those wouldn't be valid SAS variable names.
You can apply them as labels though by adding the IDLABEL line to your proc transpose code.
idlabel start_dt;
That approach generates a real ugly dataset for much use. What will you do with the transposed data?
You you are looking for a pretty table appearance then use a report procedure such as Proc Report or tabulate.
"10/26/2015" is not a valid SAS variable name. Anyway, that's not what you get with the code you posted. You can use IDLABEL=
data have;
input start_dt mmddyy10. calls 3.;
format start_dt mmddyy10.;
datalines;
10/26/2015 10
11/02/2015 12
11/09/2015 10
11/16/2015 8
;
proc sort data=have;
by start_dt;
run;
proc transpose data =have out=want (drop=_name_);
id start_dt;
idlabel start_dt;
var Calls;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.