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

Hi
I have this simple proc print:

proc print data=sashelp.class noobs label;
   var    name / style={just=left};
   var    Sex / style={BACKGROUND=white OUTPUTWIDTH=40};
   var    Age / style={BACKGROUND=white OUTPUTWIDTH=40};
   var    Height / style={BACKGROUND=red OUTPUTWIDTH=40};
   var    Weight / style={BACKGROUND=white OUTPUTWIDTH=40};
run;

Is it possible to change the Background Colour in “age” based on the values in “name” using some pre-generated formats?

For example all the students named Alfred have their own format and all students named Alice have another format? (simply a different format for each line)

Is it possible in proc report?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  For some information about PROC REPORT and styles, this paper shows some of the style changes (https://support.sas.com/resources/papers/proceedings13/366-2013.pdf). For information about how PROC REPORT works, you might want to refer to the PROC REPORT  documentation. Changing Age based on name is an example in the above paper shown on page 13.

cynthia

View solution in original post

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Yes, you need a compute section and a call style command in proc report.  Here are some examples:

http://support.sas.com/resources/papers/stylesinprocs.pdf

alr
Quartz | Level 8 alr
Quartz | Level 8

Thank you.

Is it possible to compute a group of variables?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Could you clarify the request.  You can use the group option in the define for columns. And set styles for row/col.  It may just be easier if you want something else to have a nonprinted variable to indicate a 'group' and use that to change the style of the element, though perhaps an example of what you require may clarify.

alr
Quartz | Level 8 alr
Quartz | Level 8

I have a list of KPI’s and each line should be formatted separately.

KPIID – KPI1 – KPI2 – KPI3 – KPI4 – KPI5

Then the code is:

compute kpi1;
if kpiid = 1 then
call define ('kpi1','style','style=[background=stndr.]');
endcomp;
compute kpi2;
if kpiid = 1 then
call define ('kpi2','style','style=[background=stndr.]');
endcomp;
and so on for kpi3, kpi4 and kpi5.

KPI1 to KPI5 have same background format for each KPIID.

I just thought if it is possible to reduce the code and somehow write one compute for KPI1 to KPI5 and set the format for kpi1 to kpi5.

I have 32 different KPIID with 32 different formats.

I hope my explanation make sense.

Cynthia_sas
SAS Super FREQ

Hi:

  For some information about PROC REPORT and styles, this paper shows some of the style changes (https://support.sas.com/resources/papers/proceedings13/366-2013.pdf). For information about how PROC REPORT works, you might want to refer to the PROC REPORT  documentation. Changing Age based on name is an example in the above paper shown on page 13.

cynthia

alr
Quartz | Level 8 alr
Quartz | Level 8

Thank you Cynthia, I'll look at the paper.

alr
Quartz | Level 8 alr
Quartz | Level 8

Thank you both. It works:

proc report data=mydata;

   col kpiid kpi_4 kpi_3 kpi_2 kpi_1 kpi_0;

   define kpiid       / display  ;

   define kpi_0-kpi_4 / display  ;

   compute kpi_0;

      if kpiid = 1 then do;

         call define ('kpi_0','style','style={background=myfmt.}');

         call define ('kpi_1','style','style={background=myfmt.}');

         call define ('kpi_2','style','style={background=myfmt.}');

         call define ('kpi_3','style','style={background=myfmt.}');

         call define ('kpi_4','style','style={background=myfmt.}');

      end;

   endcomp;

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1247 views
  • 3 likes
  • 3 in conversation