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.