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

Hi!

 

I am a new user to SAS and was wondering how I go about transposing my dataset. It currently looks like the following:

 

continent        industry       total

A                    0509            37

B                    0509            78

C                    0509            12

A                    1315             85

B                    1315             26

C                    1315             73

 

and I need it to look something like this:

 

                                         continent

industry     variable           A         B          C

0509          total                37        78       12

1315          total                85         26       73

 

Should I use proc transpose? Apologies if this is very simple, I am very new to SAS !! 🙂

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

To get the variable names you want, the transpose as suggested by @Amir needs some additions:

proc transpose
  data=have
  out=want (rename=(_name_=variable))
;
by industry;
id continent;
run;

View solution in original post

4 REPLIES 4
Amir
PROC Star

Hi,

 

How about:

 

proc transpose data = have
               out  = want;
   by industry;
run;

 

 

Regards,

Amir.

Kurt_Bremser
Super User

To get the variable names you want, the transpose as suggested by @Amir needs some additions:

proc transpose
  data=have
  out=want (rename=(_name_=variable))
;
by industry;
id continent;
run;
jainamistryx
Calcite | Level 5

That works perfectly - thank you so much!

data_null__
Jade | Level 19

@Kurt_Bremser wrote:

To get the variable names you want, the transpose as suggested by @Amir needs some additions:

proc transpose
  data=have
  out=want (rename=(_name_=variable))
;
by industry;
id continent;
run;

PROC TRANSPOSE has a PROC statement option NAME= to give a name to the "variable name" variable.  Kind of a 6 of 1 half dozen thing regarding which to use. 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1464 views
  • 0 likes
  • 4 in conversation