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
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 lock in 2025 pricing—just $495!
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.