BookmarkSubscribeRSS Feed
HappySASUE
Quartz | Level 8

This is a partial code of the one I am working on.  the purpose is to change "-0.0" or "-0" to "0".  I used "case" to create a new variable "New_min" and apply it to the next new variable "m".  but I failed, can anyone tell me how to do it ? Thanks.  The SAS version I am working on is 9.4.


proc sql noprint;
create table data2 as
select avisitn,

    case
        when abs(var_min) le 0.0000001 or var_min = -0 then 0
        when var_min = . then .
        else strip(put( var_min, 10.2 )) end as new_min,

 

   strip(put(round(new_min,0.01),best.))||', '|| strip(put(round(_max,0.01),best.)) end as m

from data1;
quit;

4 REPLIES 4
tomrvincent
Rhodochrosite | Level 12
put 'calculated' in front of new_min:

strip(put(round(calculated new_min,0.01),best.))||', '|| strip(put(round(_max,0.01),best.)) end as m

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002294533.htm
PGStats
Opal | Level 21

You could simplify to:

 

proc sql;
create table data2 as
select 
    avisitn,
    catx(", ", put(fuzz(var_min), 10.2), put(_max, 10.2)) as m
from data1;
quit;
PG
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1852 views
  • 3 likes
  • 3 in conversation