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-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
  • 506 views
  • 0 likes
  • 4 in conversation