BookmarkSubscribeRSS Feed
PujaDas
Calcite | Level 5

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?

 

 

8 REPLIES 8
Kurt_Bremser
Super User

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.

PujaDas
Calcite | Level 5

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

PujaDas
Calcite | Level 5
I have tried this one. But is not reflected here.

Compute col1_char;
If index_id ne 0
Then do;
If col1='0'
Then do;
Col1_char=put(col1,7.2);
Col1_char=" ";
Endcomp;

Can you please let me know where i am doing mistake?

The demo report is attached with this.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Kurt_Bremser
Super User

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;
PujaDas
Calcite | Level 5
Hi,

Yeah sorry i havnt put in with proper indentation.

One thing, here i am trying to put blank whereever the value of the column
is zero.. so in this case, i feel col1_char=" " should not be in the else
part. Am i right?

##- Please type your reply above this line. Simple formatting, no
attachments. -##
ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 929 views
  • 0 likes
  • 3 in conversation