BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Aexor
Lapis Lazuli | Level 10

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. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
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).

--
Paige Miller

View solution in original post

8 REPLIES 8
PaigeMiller
Diamond | Level 26
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).

--
Paige Miller
Aexor
Lapis Lazuli | Level 10
Can we have any option to replace missing to something else ?
Astounding
PROC Star

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?

Aexor
Lapis Lazuli | Level 10
Correct! Thanks for pointing out!
Something like charioteer value will be apt fro this .
I just want to distinguish missing to something else.
Could you please help me with this
Astounding
PROC Star

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.

PaigeMiller
Diamond | Level 26

@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?

--
Paige Miller
Aexor
Lapis Lazuli | Level 10
requirement was like this so remove missing value to something else.
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 8 replies
  • 1795 views
  • 5 likes
  • 3 in conversation