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

Hi All, 

 

I have a large dataset out of which i need to summarize and present a few numbers from it. 

My current dataset looks something like below :

 

Var1    Var2   Var3    Var4    Var5    Var6    Var7 

num1  num2  num3  num4  num5  num6  num7

 

there is nothing i could think of which would make the above dataset look like :

 

heading   heading

Var1         num1

var2         num2

Var3         num3

........... and so on. 

 

 

Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

If you post test data in the form of a datastep you are more likely to get working code.  Something like:

data have;
  set have;
  id=_n_;
run;

proc transpose data=have out=want;
  by id;
  var var:;
run;

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

If you post test data in the form of a datastep you are more likely to get working code.  Something like:

data have;
  set have;
  id=_n_;
run;

proc transpose data=have out=want;
  by id;
  var var:;
run;
Phoenix232
Fluorite | Level 6

What does Var: means ? 

 

sorry, been programming after ages that i have forgotten even basic things. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Its a shorthand method of stating any variable with teh prefix given, so if I said:

abcd:

This would include any variable name with abcd as first four characters e.g. abcd1234, abcde, but not efg_abcd.

You could also use -- to specify a range (per sort order) of variable names and such like.

http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtq...

Phoenix232
Fluorite | Level 6

Thanks a ton, Your solution worked perfectly but i tweaked a bit.

 

I had mixed variable names and var: only targeted the specific ones.. i removed this line and dropped the id from the dataset to give out the desired results.. 

 

 

🙂 🙂 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1342 views
  • 0 likes
  • 2 in conversation