BookmarkSubscribeRSS Feed
75063
Obsidian | Level 7

Good evening, 

 

Wanted to know if it is possible to get the following template output from a sas code. The input files from where I need to create the template are in excel.  The following is my query: 

 

I am not sure how to get the branched out variable names. For example in the attached file that I have provided variable " Enrollment" has three sub variables namely 1. "2013" 2. "2014" and 3 "% Change".

 

Secondly, is it possible to highlight  variable names and filling the cells with color in sas code?  

 

I am using SAS on demand for academics. 

 

Thanking all in advance.   

 

 

5 REPLIES 5
Kurt_Bremser
Super User

First of all, SAS does not have "cells". SAS has rows and columns.

The columns are one-level only. In proc report, you can span headers over columns, but that's for reporting purposes only.

Next. SAS variables contain characters or numbers. Coloring comes only into play, once again, when creating reports. Data in datasets does not have color, as it makes no sense in a SAS context.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

You can get there, it will take a fair bit of working through.  Some starters:

ods excel file="want.xlsx" style=minimal;

proc report data=have nowd;
  columns main_status 
                 ("Enrolment" enrol_2013 enrol_2014 chg)
                 ("Work hours" ...;
  define main_status / "Main Status" style(column)={cellwidth=4cm};
  define enrol_2013 / "2013" style(column)={cellwidth=1cm};
  define...
run;

ods excel close;

As you have not posted any test data in the form of a datastep, it is impossible to provide anything more than examples.  The above assumes a dataset which already has the calculations done in a datastep - which is a simpler way of working.

75063
Obsidian | Level 7

Thank you for the starter code. I have attached the sample of the data set along with this post. Looking forward to further guidance in the code.  

 

 

Also, after writing the following code -

 

 Proc Report Data= Sams nowd;
column FT (" sdfsfs" TERM_DESC roll );
define TERM_DESC / group;
define FT / group;
Run;

 

I got the output as - 
 

  sdfsfsFT TERM_DESC roll

FULL TIMEFall 20161566
 Fall 20171638
PART TIMEFall 2016496
 Fall 2017677

  

 

is it possible to transpose the "Fall2016" and "Fall 2017" to columns from the Proc report step and have the "roll" variable as the rows so that the output looks like - 

 

FTFall 2016Fall 2017 
FULL TIME15661638
PART TIME496667

 

 

Thanking you! 

75063
Obsidian | Level 7

I have used the following code to transpose 

 

proc report data=UNIVERSI.univ2016_17
out=lat(drop=_break_) nowd;
column FT TERM_DESC, roll;
define FT/group noprint;
define TERM_DESC/across noprint;
define roll/sum noprint;
quit;

 

However the output is 

Obs FT_C2__C3_
1FULL TIME15661638
2PART TIME497677

 

can i rename the variable from c2, c3 to Fall2016 and Fall2017 ? 

 

Thank you!

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Use a proc transpose before the proc report and get your data looking the way you want it to look before reporting.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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