The SAS Output Delivery System and reporting techniques

Proc report/ODS and formatting with call define

Reply
Contributor NWV
Contributor
Posts: 29

Proc report/ODS and formatting with call define

Hello, Today, using syntax I found in this forum, I used proc report and the call define terminology to create some custom colored output.  It worked fine, but I'm wondering if there was an easier way to do it for my dataset. I have 10 records, lab data each analyzed for 31 metals.  Each of the 31 metals is a variable, with a concentration listed for each sample.  I also have 31 flag variables 9one for each metal) indicating whether it was above or below a certain value.  I used the flag values (defined but not displayed) to create color coded output (traffic lighting). For example-- compute Tin; if (DQF_Tin="<") then call define ("Tin","style","style=[foreground=purple]"); else if (DQF_Tin="()") then call define ("Tin","style","style=[foreground=green]"); endcomp; compute Titanium; if (DQF_Titanium="<") then call define ("Titanium","style","style=[foreground=purple]"); else if (DQF_Titanium="()") then call define ("Titanium","style","style=[foreground=green]"); endcomp; There are 31 of these statements, one for each of the metals.  Was there an easier way?  I needed the 31 metal colums (plus a sample id) in the output, so I guess I have to define them all?  No shortcut? Thoughts appreciated. Thank you, Nicole

PROC Star
Posts: 7,363

Proc report/ODS and formatting with call define

If you post your code, and a short datastep showing what you datafile looks like, I'm sure that someone could suggest a shortcut.

Super User
Posts: 17,828

Proc report/ODS and formatting with call define

Use a format in your call define. Check this paper out:

http://support.sas.com/resources/papers/proceedings10/153-2010.pdf

Vince provides an example using proc report and proc print.

The proc report example is almost identical to what you're doing.

PROC Star
Posts: 7,363

Proc report/ODS and formatting with call define

I totally agree that you ought to look at Vince's paper and using the methods he suggests will save you quite a bit of time.

But, even though Vince probably knows more about the topic than anyone, you can still save some keystrokes by expanding his code even further.

For example, Vince uses the following statements in applying the formats:

array name(10) $31 ('Haemoglobin_Result' 'Haematocrit_Result' 'RBC_Result'

                      'WBC_Result' 'Lymphocytes_Result' 'Monocytes_Result'

                      'Neutrophils_Result' 'Eosinophils_Result' 'Basophils_Result'

                      'Platelets_Result');

 

array flag(10) Haemoglobin_Flag Haematocrit_Flag RBC_Flag WBC_Flag

                 Lymphocytes_Flag Monocytes_Flag Neutrophils_Flag Eosinophils_Flag

                 Basophils_Flag Platelets_Flag;

Actually, if you look at the data, Vince only used 10 of the 17 result and flag variables.  If you were actually interested in all of them, the keystrokes could be further reduced by using something like:

proc sql noprint;

  select quote(propcase(trim(name))) into :names

    separated by " "

      from dictionary.columns

         where libname eq "SAMPLE" and

               memname eq "LABRESULTS" and

               name like '%_result'

;

  select propcase(trim(name)) into :flags

    separated by " "

      from dictionary.columns

         where libname eq "SAMPLE" and

               memname eq "LABRESULTS" and

               name like '%_flag'

;

quit;

array name(17) $31 (&names.);

array flag(17) &flags.;

Of course, you could also use the same technique in a number of other places in his example code.

HTH,

Art

Ask a Question
Discussion stats
  • 3 replies
  • 178 views
  • 0 likes
  • 3 in conversation