G'day I am attempting to use a "star" system for reporting with and would like to insert wingding "stars" conditional on a variable in the dataset. The conditional-if is not executing... HELP! (much obliged and thanks.....)
ods escapechar='^';
ods pdf file='temp.pdf';
proc report data=sashelp.class nowd ;
col age new sex name;
define new / format=$30. ;
define sex / noprint ;
define name / display;
compute new/char ;
if sex = "M" then new='^S={font_face=wingdings} ²'; else new='^S={font_face=wingdings} ²²²²²²';
endcomp;
run;
ods pdf close;
Hello,
You need to change the order of variables on the COLUMN statement. PROC REPORT processes variables in the order in which they are named on the COLUMN statement. Variables referenced in a COMPUTE block cannot refer to variables listed to their right in the COLUMN statement.
col age sex new name;
Hi:
Well, you can't compute NEW the way your column statement is coded right now, since it is on the wrong side of SEX in the COLUMN statement. Look for previous postings on PROC REPORT and "left to right processing".
Think of PROC REPORT as building each single report row one column item at a time. So first, PROC REPORT places AGE on the report row, then it places NEW on the report row. There's a COMPUTE block for NEW. However, at the point where PROC REPORT is trying to build NEW, the variable SEX has not been placed on the report row, so the COMPUTE block has no visibility of the value for SEX. SEX can still be a NOPRINT item, it just has to be on the -other- side of NEW if you want to use the SEX variable in the COMPUTE block for NEW. In the same fasion, when PROC REPORT is placing the SEX column on the report, it hasn't yet placed NAME on the report -- so if you wanted to do some form of highlighting for NEW based on NAME, that wouldn't work either.
And, there's an easier way to do your code, I think. All you need to do is assign the correct hex value to NEW ('AB'x is the black star and 'B5'x is the white star in a black circle) -- to find the hex value for other Wingding characters, use Windows character map or look at a map of the Wingdings font. And then you don't need to use ODS ESCAPECHAR (unless you really want to for some other reason). See attached screenshot.
cynthia
Just as NickR said. You need to put sex variable(noprint) before new variable.
ods escapechar='^';
ods pdf file='temp.pdf';
proc report data=sashelp.class nowd ;
column sex age new name;
define sex/noprint;
define new / format=$30. ;
define name / display;
compute new/char ;
if sex = "M" then new='^S={font_face=wingdings} ²'; else new='^S={font_face=wingdings} ²²²²²²';
endcomp;
run;
ods pdf close;
Ksharp
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: