3

I'm writing a macro that takes in a dataset with an unknown number of columns (both character and numeric), but it is known that 1 column is called obsId.

I'd like to proc transpose the contents of the entire table by ObsId, without knowing the names of the other columns. Is this doable without doing something crazy like looking it up in dictionary.columns?

Sample Dataset

ObsId Name Age Height
1     John 15  170 
2     Joe  34  160

Desired Output

ObsId _name_ col1
1     Name   John
1     Age    15
1     Height 170
2     Name   Joe
2     Age    34
2     Height 160

Equivalent Code

proc transpose data=dataset;
by ObsId;
var Name Age Height;
run;

Again, I'd like to be able to do this with any generic dataset which has a column named ObsId and an unspecified number of other columns.

Any input would be appreciated.

flag

1 Answer

1

Hello,

You can use it ( _ALL_: references all vars):

proc transpose data=dataset out=dataset2;  
by ObsId;  
var _ALL_;  
run;

Regards,
Toloc

link|flag
Thanks, that's exactly what I'm looking for. – Joseph Dec 7 at 18:49

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.