BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
deliansteel
Calcite | Level 5

I proc transposed this:

Capture3.PNG

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:

Capture.PNG

 

but I want something like this

Capture2.PNG

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

4 REPLIES 4
Reeza
Super User

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;
deliansteel
Calcite | Level 5
Thank you!
PGStats
Opal | Level 21

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;
PG
deliansteel
Calcite | Level 5
Thank you also for your help!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 822 views
  • 0 likes
  • 3 in conversation