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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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:

Cynthia_sas_0-1596210590971.png

 

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.

Cynthia_sas_1-1596210860510.png

  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

 

 

View solution in original post

5 REPLIES 5
ghosh
Barite | Level 11

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

RandoDando
Pyrite | Level 9
proc format ;
value missing . = "No Data Available";
run;

proc format;
value colorflag 1='BILG'
2='gold'
3='orange'
4='VIYPK'
0='White';
run;
Shmuel
Garnet | Level 18

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.

Cynthia_sas
SAS Super FREQ

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:

Cynthia_sas_0-1596210590971.png

 

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.

Cynthia_sas_1-1596210860510.png

  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

 

 

RandoDando
Pyrite | Level 9

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 716 views
  • 0 likes
  • 4 in conversation