BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Arora_S
Obsidian | Level 7

Have an interesting SAS Question and if it can be done in proc report . The input dataset looks like this :

name col1  percent1 col2  percent2
abc 45 0.12 56 0.32
def 34 0.25 45 0.80

  

Output report needed on a pdf  document with the name variable as by variable on separate pages  like this : used byvalue() option on the title but columns are not getting transposed to desired format. Any help is highly appreciated. thanks in advance

title >>>>>  byname - abc   page1
  column_header percent_header    
col1 45 12%    
col2 56 25%    

 

title >>>>>  byname - def   page2
  column_header percent_header    
col1 34 25%    
col2 45 80%    

 

Basically I am trying to align columns as rows with description.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
You only need to post this one time, to prevent multiple people from working on the same question in different forums.
One suggestion is already posted here:
https://communities.sas.com/t5/ODS-and-Base-Reporting/Interesting-Report-Question/m-p/294989

cynthia

View solution in original post

5 REPLIES 5
Arora_S
Obsidian | Level 7

Have an interesting SAS Question and if it can be done in proc report . The input dataset looks like this :

name col1  percent1 col2  percent2
abc 45 0.12 56 0.32
def 34 0.25 45 0.80

  

Output report needed on a pdf  document with the name variable as by variable on separate pages  like this : used byvalue() option on the title but columns are not getting transposed to desired format. Any help is highly appreciated. thanks in advance

title >>>>>  byname - abc   page1
  column_header percent_header    
col1 45 12%    
col2 56 25%    

 

title >>>>>  byname - def   page2
  column_header percent_header    
col1 34 25%    
col2 45 80%    

 

Basically I am trying to align columns as rows with description.

Cynthia_sas
SAS Super FREQ
Hi:
You only need to post this one time, to prevent multiple people from working on the same question in different forums.
One suggestion is already posted here:
https://communities.sas.com/t5/ODS-and-Base-Reporting/Interesting-Report-Question/m-p/294989

cynthia
Cynthia_sas
SAS Super FREQ

Hi:

  By default, PROC REPORT will not "stack" variables as you envision. You would have to restructure the data to use PROC REPORT. Then, you can either use BY group processing or COMPUTE BEFORE _PAGE_ to get the type of header you want. I show the NAME variable column on my screen shot just so you can see how it is used. But if you did not want to see name, you could always use NOPRINT on the DEFINE statement for NAME.

 

cynthia

restructure_for_report.png

Arora_S
Obsidian | Level 7
I am trying to use ods layout with ods region as a way to show the output instead of title approach. However not sure if we can use byvar/byval option as in title for proc report .secondly how can we print the output side by side on a same page .
Cynthia_sas
SAS Super FREQ

Hi:

  You haven't posted any code or any data so it's hard to envision how you're using ODS LAYOUT and ODS REGION to do this.  #BYVAR and #BYVAL are designed to work in a SAS title only. So there are not many other places where you can use those tokens. They are treated as text every place else.

 

  In your original post, you showed the BY group tables one under the other, as though each one was on a separate page. If you are using PDF, you can frequently get small tables placed side by side merely by using COLUMNS=2, as shown here: https://communities.sas.com/t5/SAS-Procedures/Show-additional-information-in-tabular-cells/td-p/2930... scroll down to the post that shows 2 tables side by side created with PROC REPORT.

 

cynthia

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 1132 views
  • 3 likes
  • 2 in conversation