BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
scolitti1
Calcite | Level 5

Hi,

 

I have created an automated report, and I was asked to put in the verbiage (increased/decreased/did not change) on a certain line in the report. I was thinking of doing an if/then statement, but I am still trying to figure out how to identify negative and positive values. 

 

The line of code for the report is below. The "increased/decreased/did not change" is dependent on "&DIF_confirmedcount" variable. If the DIF_confirmed out has a negative value, I want it to say "decreased", positive value="increased", and 0="did not change". 

 

PUT "• The number of currently hospitalized patients (placeholder) by &DIF_confirmedcount. (&DIF_bullet3. change) to &bullet3. from the previous reporting day.";

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
%if %eval(&dif_confrimendcount<0) %then %let placeholder=decreased;
%else %if %eval(&dif_confrimendcount>0) %then %let placeholder=increased;
%else %let placeholder=did not change;
PUT "• The number of currently hospitalized patients &placeholder by %sysfunc(abs(&DIF_confirmedcount.)) (&DIF_bullet3. change) to &bullet3. from the previous reporting day.";
--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26
%if %eval(&dif_confrimendcount<0) %then %let placeholder=decreased;
%else %if %eval(&dif_confrimendcount>0) %then %let placeholder=increased;
%else %let placeholder=did not change;
PUT "• The number of currently hospitalized patients &placeholder by %sysfunc(abs(&DIF_confirmedcount.)) (&DIF_bullet3. change) to &bullet3. from the previous reporting day.";
--
Paige Miller
PaigeMiller
Diamond | Level 26

Even simpler, use different wording

 

PUT "• The number of currently hospitalized patients has changed by &DIF_confirmedcount. (&DIF_bullet3. change) to &bullet3. from the previous reporting day.";
--
Paige Miller
scolitti1
Calcite | Level 5

Thanks,

 

I originally tried this wording, but was asked to add in increase/decrease/did not change. 

PaigeMiller
Diamond | Level 26

A great example of micro-managing, which unfortunately I have run into as well. Very frustrating.

--
Paige Miller
ballardw
Super User

@scolitti1 wrote:

Hi,

 

I have created an automated report, and I was asked to put in the verbiage (increased/decreased/did not change) on a certain line in the report. I was thinking of doing an if/then statement, but I am still trying to figure out how to identify negative and positive values. 

 

The line of code for the report is below. The "increased/decreased/did not change" is dependent on "&DIF_confirmedcount" variable. If the DIF_confirmed out has a negative value, I want it to say "decreased", positive value="increased", and 0="did not change". 

 

PUT "• The number of currently hospitalized patients (placeholder) by &DIF_confirmedcount. (&DIF_bullet3. change) to &bullet3. from the previous reporting day.";

 


Personally think that you have left a great many details. I am assuming that since you are using PUT that perhaps you are using a data step to write this. In which case it may be possible to use a FORMAT assigned to the variable (assuming one is actually used)

This is trivial example.

proc format ;
value change
low-<0='decreased'
0     ='no change'
0<-high= 'increased'
;

data _null_;
   input x;
   put "The count of something " x change. " by " x "some following boiler plate";
datalines;
-34
0
15
0.00001
-999999999
;

Which creates output

The count of something decreased by -34 some following boiler plate
The count of something no change by 0 some following boiler plate
The count of something increased by 15 some following boiler plate
The count of something increased by 0.00001 some following boiler plate
The count of something decreased by -999999999 some following boiler plate

If this is not applicable then show some details.

Note that if the variable name is held in a macro variable you can replace the X that I used with the macro variable.

 

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1678 views
  • 2 likes
  • 3 in conversation