My dataset is in SAS. In the dataset currently, each row represents one observation and each column represents one variable.
But I need to create and export a version of my SAS dataset in which each column represents one observation, and each row represents one variable.
In other words, I want to go from something like this...
| Fname | Lname | Age | Zipcode | |
| 1 | John | Smith | 32 | 30303 |
| 2 | Mary | Jones | 28 | 30304 |
| 3 | Sue | Wilson | 54 | 30305 |
| 4 | Bob | Anders | 43 | 30306 |
| 5 | Sam | Rogers | 19 | 30307 |
| 6 | Chris | Doe | 27 | 30308 |
| 7 | Tom | Smith | 18 | 30309 |
| 8 | Kate | Adams | 41 | 30310 |
| 9 | Greg | Wade | 38 | 30311 |
to this...
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
| Fname | John | Mary | Sue | Bob | Sam | Chris | Tom | Kate | Greg |
| Lname | Smith | Jones | Wilson | Anders | Rogers | Doe | Smith | Adams | Wade |
| Age | 32 | 28 | 54 | 43 | 19 | 27 | 18 | 41 | 38 |
| Zipcode | 30303 | 30304 | 30305 | 30306 | 30307 | 30308 | 30309 | 30310 | 30311 |
In MS Excel, I can do this using the option "Edit >> Copy >> Paste Special >> Transpose" but I need to do this operation in SAS and not in Excel.
My SAS dataset is too large for me to manipulate manage it in Excel, so manually using the "Transpose" feature in Excel is not an option for me.
Any suggestions?
proc transpose data=sashelp.class out=class;
var _all_;
run;
THANK YOU! Worked perfectly. Awesome!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.