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

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 1024 views
  • 3 likes
  • 3 in conversation