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.
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.
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.
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 TIME | Fall 2016 | 1566 |
Fall 2017 | 1638 | |
PART TIME | Fall 2016 | 496 |
Fall 2017 | 677 |
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 -
FT | Fall 2016 | Fall 2017 |
FULL TIME | 1566 | 1638 |
PART TIME | 496 | 667 |
Thanking you!
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_ |
1 | FULL TIME | 1566 | 1638 |
2 | PART TIME | 497 | 677 |
can i rename the variable from c2, c3 to Fall2016 and Fall2017 ?
Thank you!
Use a proc transpose before the proc report and get your data looking the way you want it to look before reporting.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.