Desktop productivity for business analysts and programmers

Tranposing a Table - Columns to Rows

Reply
New Contributor
Posts: 2

Tranposing a Table - Columns to Rows

Hello ang good day everyone,

 

I am very new to EG.

 

I have several SAS data sets that I would like to adjust. For some I would like to take the row headers and put them into column headers, and others I would like to put the column headers and move them into row headers.

 

Can you please help with this?

 

Also, any good books I can get to help me with working through examples?

 

 

Thanks for your feedback.

Super User
Posts: 11,104

Re: Tranposing a Table - Columns to Rows

It helps to provide example data, not as Excel, many of us don't want to open such files from unknown sources. Show what you have and what you want.

SAS has a procedure named transpose that has the purpose of reshaping data as you request but the devil is in the details.

For instance are your "row labels", such is not a concept for SAS data sets, text or numeric? Since the variables (columns) are restricted in naming your desired values may not work because variable names must start with _ or letter (not numerals) and the other characters may only be letters, digits or the _ character with a limit of 32 characters. HOWEVER SAS has the concept of a variable label with can be quite longer and is used to provide nice displays in most procedures or output.

 

I recommend starting with the SAS online help if installed. There is a section title 'Learning to Use SAS' which has example programs and data.

There is also some free on line classes available at: https://support.sas.com/edu/elearning.html?ctry=us&productType=library

 

Super User
Posts: 19,023

Re: Tranposing a Table - Columns to Rows

https://stats.idre.ucla.edu/sas/modules/

The bottom of the page has specific links on transforming your data - ie long to wide and wide to long

Classic Data Management Problems
Merging Data Files via Data Step, Proc SQL
Concatenating (stacking) SAS data files
Working across variables
Collapsing across observations in SAS via Proc Means, Proc SQL , Data Step I , Data Step II
Reshaping data from wide to long via Proc Transpose , Data Step
Reshaping data from long to wide via Proc Transpose , Data Step
New Contributor
Posts: 2

Re: Tranposing a Table - Columns to Rows

Hello everyone,

 

Here is the data that I'm looking at as an example. I have placed it as a attachment.

 

Thank you for the quick response.

 

 


SAS Photo.JPG
Super User
Posts: 19,023

Re: Tranposing a Table - Columns to Rows

You showed us a data set. That's great. Now what are you trying to do with it? 

 

Note that if you ever want code as a solution and you post an image, how would you expect us to work with the image. Based on what you've provided, the answer stands as it is. Please see the links in my previous post.

Ask a Question
Discussion stats
  • 4 replies
  • 167 views
  • 0 likes
  • 3 in conversation