Hello everyone,
When I want to print all observations under a variable, it prints them in a column format (i.e., each observation is listed right below the previous one). However, how can I print all observations in a row format (i.e., all observations are listed adjasent to each other)?
Any idea/thought is really appreciated!
You'll need to manually use a PUT statement within a data step to control your output.
Or you could select the row, transpose your data and then use PROC PRINT.
If this is something you do regularly I'd probably create a macro to handle this issue.
Show an example starting data set and the desired resulting data set.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
@Alireza_Boloori wrote:
I'd be very thankful if you can create a macro, because this is not going to be a one-time SAS code for me.
I'm happy to help, not to write your code. If this is not a one time use you should also understand it thoroughly. I suggest coding it for a 'Base case' then we can help you turn it into a macro. For example, how to get all Names from SASHELP.CLASS on a single line. You didn't want any delimiter between the values?
See the PUT Statement Documentation for examples
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!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.