I have a two data sets (one for each date) with the same variables, including general state and county info (which does not change), date, and a score value. I want to create a report from the combined set which groups by state and county, and has the date values (2 of them so far) going across with the score values below each. The scores are AS IS in the data, no summing. I also want to format the score values according to the value, which I have in a saved format.
I run this code and I get no formatting beneath the dates, and an additional column for score on the right which I do not want.
proc report data=CNTY_TREND_FINAL nowd;
columns state_cd state_name county_name FIPS DATE score;
define state_cd / group ;
define state_name /group ;
define county_name /group ;
define FIPS/ group ;
define DATE/across order=data 'Date of Data';
define score / analysis format=missing. style(column)={background=colorflag.};
run;quit;
Hi:
Usually, when you use ACROSS, you use a comma operator, as shown here using SASHELP.CLASS. Notice the difference between the way the 2 different reports look:
Since you didn't post your data, no one can test or correct your code without making some fake data. However, if I build on my second report, with a user defined format, the format works for me.
In order to code the format, I did need to have some idea of what the values for HEIGHT would be once they were nested underneath each unique value for the SEX variable.
Hope this helps,
Cynthia
You have not provided sufficient information. for example, your proc format.
for starters, check this out
https://www.lexjansen.com/wuss/2006/tutorials/TUT-Carpenter.pdf
proc format ;
value missing . = "No Data Available";
run;
proc format;
value colorflag 1='BILG'
2='gold'
3='orange'
4='VIYPK'
0='White';
run;
You wrote: "I run this code and I get no formatting beneath the dates, and an additional column for score on the right which I do not want. "
Please post your output and the output you expected.
Hi:
Usually, when you use ACROSS, you use a comma operator, as shown here using SASHELP.CLASS. Notice the difference between the way the 2 different reports look:
Since you didn't post your data, no one can test or correct your code without making some fake data. However, if I build on my second report, with a user defined format, the format works for me.
In order to code the format, I did need to have some idea of what the values for HEIGHT would be once they were nested underneath each unique value for the SEX variable.
Hope this helps,
Cynthia
That's it! I knew it was something simple, and I apologize for not being clear enough about my output. Thanks!
proc report data=CNTY_TREND_FINAL nowd;
columns state_cd state_name county_name FIPS DATE, score;
define state_cd / group ;
define state_name /group ;
define county_name /group ;
define FIPS/ group ;
define DATE/across order=data 'Date of Data';
define score / analysis format=missing. style(column)={background=colorflag.};
run;quit;
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.