DATA Step, Macro, Functions and more

turn one row from an existing table into a column

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

turn one row from an existing table into a column

It seems like this should be pretty simple, but I can't find a way to make it work.  I have a table with multiple observations and 20 variables.  I want to pull one observation from that table and put the values into a column.

 

When I try proc transpose it only gives me half the variables, namely those with numerical values.

 

I just need to go from this:

namethisthatotherthose
Bob5male425/31/2016

 

to this:

Bob
5
male
42
5/31/2016

 

Is there any easy way to do this?


Accepted Solutions
Solution
‎05-13-2016 11:47 AM
Trusted Advisor
Posts: 1,118

Re: turn one row from an existing table into a column

Hi @grungoo,

 

By default, PROC TRANSPOSE transposes only numeric variables, but if you list character variables in the VAR statement, they will be transposed as well. So, the simplest way to transpose all variables is probably to use the statement

var _all_;

in the PROC TRANSPOSE step.

View solution in original post


All Replies
Solution
‎05-13-2016 11:47 AM
Trusted Advisor
Posts: 1,118

Re: turn one row from an existing table into a column

Hi @grungoo,

 

By default, PROC TRANSPOSE transposes only numeric variables, but if you list character variables in the VAR statement, they will be transposed as well. So, the simplest way to transpose all variables is probably to use the statement

var _all_;

in the PROC TRANSPOSE step.

New Contributor
Posts: 2

Re: turn one row from an existing table into a column

Posted in reply to FreelanceReinhard

I knew it had to be something simple.  Thank you!

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 184 views
  • 0 likes
  • 2 in conversation