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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1334 views
  • 0 likes
  • 2 in conversation