- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am bit new to SAS, I searched the boards but could not find an answer to the dilemma I am facing -
I have a SAS Data Set that looks like the attached picture, as you can see that Once address could have multiple phone numbers and/or multiple First Name. I am trying to transpose this data do I can see it something like this (as headings and then the data underneath) -
Address First Name1 First Name2 FirstName...n Phone1 Phone2 Phone3 Phone4 Phone...n
For Example for first two records, I would like to see:
1 52 2 Niagara Menzies Justin Menzies Justin 5198450640 5198451608
if there are multiple names or phone numbers then a extra column gets added for each...
Any help is much appreciated....Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You're transposing multiple varialbes so you'll need to eitehr:
1. Use an ARRAY() https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/
2. Use multiple PROC TRANSPOSE and merge the results. https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/
The latter is usually easier if you're a beginner.
There's a macro called 'A Better Way to Flip" and you can use that to get what you want as well.
http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset
@SNG1 wrote:
Hi All,
I am bit new to SAS, I searched the boards but could not find an answer to the dilemma I am facing -
I have a SAS Data Set that looks like the attached picture, as you can see that Once address could have multiple phone numbers and/or multiple First Name. I am trying to transpose this data do I can see it something like this (as headings and then the data underneath) -
Address First Name1 First Name2 FirstName...n Phone1 Phone2 Phone3 Phone4 Phone...n
For Example for first two records, I would like to see:
1 52 2 Niagara Menzies Justin Menzies Justin 5198450640 5198451608
if there are multiple names or phone numbers then a extra column gets added for each...
Any help is much appreciated....Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks...worked perfect