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

Hi,

I am trying to use PROC TRANSPOSE to transpose from wide to narrow and entire dataset.

This is what I have.

IDSALARYNAMEHIRE_DATEBONUSDEPT
001001100,000JONES SMITH0101201010,000ADMIN
00100258,362HARRY WIZARD020520055,600SALES
00100385,254JOHN ADAMS101020093,055SALES

This is the expected outcome I need.

ID001001001002001003
SALARY100,00058,36285,254
NAMEJONES SMITHHARRY WIZARDJOHN ADAMS
HIRE_DATE010120100205200510102009
BONUS10,0005,6003,055
DEPADMINSALESSALES

I am trying to use PROC TRANSPOSE, but I havent been able to obtain the expected result.  Any help?

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
data id;
   infile cards firstobs=2 dsd dlm='|';
  
input ID :$4. SALARY:comma. NAME:$16. HIRE_DATE:mmddyy. BONUS:comma. DEPT :$8.;
  
format salary bonus comma12. hire_date mmddyy10.;
  
cards;
ID,SALARY,NAME,HIRE_DATE,BONUS,DEPT
1001|100,000|JONES SMITH|1012010|10,000|ADMIN
1002|58,362|HARRY WIZARD|2052005|5,600|SALES
1003|85,254|JOHN ADAMS|10102009|3,055|SALES
;;;;
proc print;
  
run;
proc transpose data=id out=id2 name=ID;
   id id;
   var salary--dept;
   run;
proc print;
  
run;


10-24-2014 10-26-27 AM.png

View solution in original post

1 REPLY 1
data_null__
Jade | Level 19
data id;
   infile cards firstobs=2 dsd dlm='|';
  
input ID :$4. SALARY:comma. NAME:$16. HIRE_DATE:mmddyy. BONUS:comma. DEPT :$8.;
  
format salary bonus comma12. hire_date mmddyy10.;
  
cards;
ID,SALARY,NAME,HIRE_DATE,BONUS,DEPT
1001|100,000|JONES SMITH|1012010|10,000|ADMIN
1002|58,362|HARRY WIZARD|2052005|5,600|SALES
1003|85,254|JOHN ADAMS|10102009|3,055|SALES
;;;;
proc print;
  
run;
proc transpose data=id out=id2 name=ID;
   id id;
   var salary--dept;
   run;
proc print;
  
run;


10-24-2014 10-26-27 AM.png

sas-innovate-2024.png

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.

 

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
  • 1 reply
  • 926 views
  • 0 likes
  • 2 in conversation