As attached, my data named "try" was generated by "proc summary" in previous step. Now I want to use "proc transpose" to reformat the data using the following code
proc sort data=try; by level id year; run;
proc transpose data=try
out=try1;
var nclass;
by level id year;
run;
But got the result as the attached data try1.
I seems there is issue of my "try" data. please help.
thanks!
Not clear what you want, but you probably want to use YEAR as an ID variable instead of BY variable.
proc transpose data=try out=want prefix=Year_ ;
by level id ;
id year;
var nclass;
run;
proc print data=want; run;
Year_ Year_ Year_ Year_ Year_ Year_ Year_ Obs level id _NAME_ 2013 2014 2015 2016 2017 2018 2019 1 PT 0001 nclass 44 37 45 44 43 39 41 2 PT 0002 nclass 55 53 54 55 49 51 56 3 PT 0008 nclass 28 42 38 35 38 40 38
Not clear what you want, but you probably want to use YEAR as an ID variable instead of BY variable.
proc transpose data=try out=want prefix=Year_ ;
by level id ;
id year;
var nclass;
run;
proc print data=want; run;
Year_ Year_ Year_ Year_ Year_ Year_ Year_ Obs level id _NAME_ 2013 2014 2015 2016 2017 2018 2019 1 PT 0001 nclass 44 37 45 44 43 39 41 2 PT 0002 nclass 55 53 54 55 49 51 56 3 PT 0008 nclass 28 42 38 35 38 40 38
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.