This Table has temperatures(temp1 to temp6) in Celsius. I need convert it to Fahrenheit.
I have this table
data temp;
input temp1 temp2 temp3 temp4 temp5 temp6;
datalines;
90 20 90 55 48 20
80 . 33 87 49 79
40 20 80 55 38 20
90 . 63 87 99 89
;
run;
I want this conversion Temp1 = Temp1 × 9/5 + 32 for every temp1 to temp6 and also for missing value we need to replace it with 99.
Please help me with this.
data temp;
input temp1 temp2 temp3 temp4 temp5 temp6;
datalines;
90 20 90 55 48 20
80 . 33 87 49 79
40 20 80 55 38 20
90 . 63 87 99 89
;
run;
data want;
set temp;
array t temp:;
do i=1 to dim(t);
t(i)=t(i)*1.8+32;
end;
drop i;
run;
I would strongly advice against replacing a missing with a non-missing in this case. So I am not going to code that. (Yes, in some modeling or other analyses, people impute a value for a missing, which is fine, but they don't replace missings with 99).
data temp;
input temp1 temp2 temp3 temp4 temp5 temp6;
datalines;
90 20 90 55 48 20
80 . 33 87 49 79
40 20 80 55 38 20
90 . 63 87 99 89
;
run;
data want;
set temp;
array t temp:;
do i=1 to dim(t);
t(i)=t(i)*1.8+32;
end;
drop i;
run;
I would strongly advice against replacing a missing with a non-missing in this case. So I am not going to code that. (Yes, in some modeling or other analyses, people impute a value for a missing, which is fine, but they don't replace missings with 99).
I can't begin to tell you what a horrible idea it is to change missing values to 99. What could you possibly gain by doing this? You would definitely lose. 99 is a perfectly viable temperature on a Fahrenheit scale. How would you know whether 99 represents a missing value or an actual value? How would you remove 99 when you want to compute the average temperature?
This would be a way:
if temp1 = . then temp1 = .M;
SAS supports 27 flavors of missing value for numerics, not just a dot. So missing values will print as an M instead of a dot.
When assigning a special missing value, the dot before the M is correct.
@Aexor wrote:
Something like charioteer value will be apt fro this .
I just want to distinguish missing to something else.
Can we have any option to replace missing to something else ?
I don't know what this means, or what you want here. Why isn't leaving it as missing acceptable? What is the need for something else?
@Aexor wrote:
requirement was like this so remove missing value to something else.
I'm sorry this won't help you, but this requirement is sheer madness to replace a missing with a non-missing, just because. There are indeed cases where you have a specific analysis in mind, and you replace the missing with a mean or median or some imputed value, based upon some statistical reasoning and the intended analysis, but I can't see how that applies here.
So, I hope the lesson you learn from me (which again, I understand doesn't help you) is that replacing a missing with a non-missing just for no reason whatsoever is not a good thing to do, such a bad thing to do that I won't create SAS code to do it.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.