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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1059 views
  • 0 likes
  • 3 in conversation