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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 954 views
  • 0 likes
  • 2 in conversation