BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Feyng819
Obsidian | Level 7
My original data look like this:
var1 var2 var3
1 3 C

And I want to make them look like this (splitting one row of data into four rows, var2 goes under var1, the value of var1 shows one row of data with var3 and one row of data without var3)
var1 var2 var3
1 . .
1 . C
3 . .
3 . C

Thank you!!
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

The term is TRANSPOSE

 

Transposing data tutorials:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/

Wide to Long:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/


@Feyng819 wrote:
My original data look like this:
var1 var2 var3
1 3 C

And I want to make them look like this (splitting one row of data into four rows, var2 goes under var1, the value of var1 shows one row of data with var3 and one row of data without var3)
var1 var2 var3
1 . .
1 . C
3 . .
3 . C

Thank you!!



View solution in original post

4 REPLIES 4
Reeza
Super User

The term is TRANSPOSE

 

Transposing data tutorials:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/

Wide to Long:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/


@Feyng819 wrote:
My original data look like this:
var1 var2 var3
1 3 C

And I want to make them look like this (splitting one row of data into four rows, var2 goes under var1, the value of var1 shows one row of data with var3 and one row of data without var3)
var1 var2 var3
1 . .
1 . C
3 . .
3 . C

Thank you!!



Feyng819
Obsidian | Level 7
Thank you for your help! I would like to ask that how can I get the alternative var3 value? And i tried to use transpose and my data look like
1
3
C
Im not sure if I am using the transpose correctly
Reeza
Super User

@Feyng819 wrote:

Im not sure if I am using the transpose correctly

Show your code if you're not sure if your code is correct.

Feyng819
Obsidian | Level 7
I just tried out other codes from wide to long and it works! Thank you for your help

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 485 views
  • 2 likes
  • 2 in conversation