Hi,
I am having a pdf report on sas where some rows are having value with 0.00% or else 0.0000000. The requirement is to make that row blank if the value is 0.
Can anyone suggest me what can be done to solve the issue?
For display purposes, I would create character variables, and conditionally fill those variables with put() if the value is not zero. Then use the character variables in proc print or whatever.
In proc report, you can use a compute block to achieve no output when the value is zero.
First of all thnak you for your suggesion.
For Proc Report I have tried this one :
compute index=0;
if index ^= '0' then do;
if maths='0' and history='0' and science='0'
text ' ';
Its not working.Can you please help me out with what is the correct one?
Thanks,
Puja
define index_char / computed;
compute index_char;
if index ne 0
then index_char = put(index,7.2);
else index_char = " ";
endcomp;
See http://support.sas.com/documentation/cdl/en/proc/69850/HTML/default/viewer.htm#p0rb7cj6wzrl5sn0zelfb... and other examples of the report procedure.
Look at the log!
You have do statements without corresponding end statements.
And stop writing spaghetti code; proper formatting (indentation) makes the logic visible:
compute col1_char;
If index_id ne 0
then do;
If col1 = 0 /* assuming col1 is numeric, no quotes! */
then do;
col1_char = put(col1,7.2);
end;
else do;
col1_char = " ";
end;
end;
endcomp;
Well, you have to decide about the logic. I just made the process more visible.
One approach that may work is to use a custom format so that values of 0 display as ' '. However depending on how many columns and ranges of values you are dealing with this could become cumbersome.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.