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.
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: