I proc transposed this:
proc sort data=ngr2 out=ngr1;
by no;
run;
proc transpose data=Ngr1 out=ngr;
by no;
id nigeria;
var _2011 _2012 _2013 _2014 _2015 _2016;
run;
and got this:
but I want something like this
Thanks in advance
You don't need a BY statement, in fact a 'basic' proc transpose should get you much closer:
proc transpose data=have out=want;
run;
Add back portions of code until you get what you need with the minimal amount of code. You should end up with something similar to this:
proc transpose data=have out=want;
id var_name;
var _2011 _2012 _2013 _2014 _2015 _2016;
run;
You don't need a BY statement, in fact a 'basic' proc transpose should get you much closer:
proc transpose data=have out=want;
run;
Add back portions of code until you get what you need with the minimal amount of code. You should end up with something similar to this:
proc transpose data=have out=want;
id var_name;
var _2011 _2012 _2013 _2014 _2015 _2016;
run;
I assume that variable no is only there to set a column order in your transposed table. That's fine. But it shouldn't be involved in the transposition. Simply do:
proc transpose data=Ngr1 out=ngr name=Year;
id Nigeria;
var _2011 - _2016;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.