- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have data with whole numbers values (34, 78...) in all hospitals except for one who has the numbers as (16%, 65% which ended in having .16 and .65 in the final data set...). Is there a way to change those values to whole numbers such as 16 and 65?
Thank you
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Even though you wrote the WHERE statement after the IF statement is will actually apply to the data as it is read. So your resulting dataset will only have the data from the one hospital.
If you did not intend to subset the data then instead include the extra test in the IF condition.
data new;
set test;
if variable<1 and hospital = 'abc' then variable=variable*100;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Assuming all are less than one you could do something like:
if variable<1 then variable=variable*100;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data new;
set test;
if variable<1 then variable=variable*100;
where hospital = 'abc';
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Even though you wrote the WHERE statement after the IF statement is will actually apply to the data as it is read. So your resulting dataset will only have the data from the one hospital.
If you did not intend to subset the data then instead include the extra test in the IF condition.
data new;
set test;
if variable<1 and hospital = 'abc' then variable=variable*100;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@mayasak wrote:
if variable<1 then variable=variable*100;
Hi @mayasak,
You may be lucky with your data, but in general I would use the ROUND function (or the INT function in your particular case) to ensure that the resulting numbers are exactly what you would expect:
... then variable=round(variable*100,1e-9);
Thus you avoid surprises like in this log (obtained with SAS 9.4M5 on Windows):
77 data _null_; 78 if 0.14*100~=14 & 0.29*100<29 & 0.55*100>55 then put 'Surprised?'; 79 run; Surprised? NOTE: DATA statement used (Total process time):