DATA Step, Macro, Functions and more

Need help with Proc Transpose

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Need help with Proc Transpose

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.


Accepted Solutions
Solution
‎02-07-2017 04:39 AM
Super User
Super User
Posts: 7,401

Re: Need help with Proc Transpose

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


All Replies
Solution
‎02-07-2017 04:39 AM
Super User
Super User
Posts: 7,401

Re: Need help with Proc Transpose

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;
Occasional Contributor
Posts: 9

Re: Need help with Proc Transpose

What does Var: means ? 

 

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

Super User
Super User
Posts: 7,401

Re: Need help with Proc Transpose

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

Occasional Contributor
Posts: 9

Re: Need help with Proc Transpose

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

 

 

Smiley Happy Smiley Happy 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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