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

Hi there,

 

I tried to transpose a table, see below example:

 

ID Age1 Age1
A 10 20
C 30 40
D 50 60
E 70 80

 

I want:

AGE A C D E
Age1 10 30 50 70
Ag2 20 40 60 80
         

 

Any help will be very appreciated.

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

proc transpose data=have out=want;
id id;
var code1 code2;
run;

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20


data have;
input ID $ Age1 Age2;
datalines;
A 10 20
C 30 40
D 50 60
E 70 80
;

proc transpose data=have out=want;
id id ;
run;

 

You could have tried yourself. it's easy copy paste

ursula
Pyrite | Level 9

Thank you!

 

I wonder if the variable Age1 and Age1 are characters, then the code is not working.

This is the other example:

 

ID code1 code2
A x h
C t j
D f b
E t h

 

I want:

CODE A C D E
code1 x t f t
code2 h j b h
novinosrin
Tourmaline | Level 20

proc transpose data=have out=want;
id id;
var code1 code2;
run;

soham_sas
Quartz | Level 8

@ursula you can try the below,

 

data have;
input ID $ Age1 Age2;
datalines;
A 10 20
C 30 40
D 50 60
E 70 80
;
run;

proc transpose data=have;
var age:;
ID ID;
run;

ursula
Pyrite | Level 9

Perfect! 

Thank you so much.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

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
  • 5 replies
  • 1041 views
  • 1 like
  • 3 in conversation