BookmarkSubscribeRSS Feed
Alireza_Boloori
Fluorite | Level 6

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!

 

 

4 REPLIES 4
Reeza
Super User

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.

Alireza_Boloori
Fluorite | Level 6
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.
ballardw
Super User

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. 

 

Reeza
Super User

@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

 http://support.sas.com/documentation/cdl/en/lestmtsref/69738/HTML/default/viewer.htm#n1spe7nmkmi7ywn...

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1901 views
  • 0 likes
  • 3 in conversation