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
If you post your code, and a short datastep showing what you datafile looks like, I'm sure that someone could suggest a shortcut.
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.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: