Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am new to SAS and am working with a data set that deals with a numeric variabl

ID: 3320938 • Letter: I

Question

I am new to SAS and am working with a data set that deals with a numeric variable 'width'. This variable has multiple missing values which appear as '.' and I need to convert these so they appear as 'No Sample' in the results. If I just converted to zero I would just do:

But since I need to change it to a character I am unsure what to do.

Thanks

down votefavorite

I am new to SAS and am working with a data set that deals with a numeric variable 'width'. This variable has multiple missing values which appear as '.' and I need to convert these so they appear as 'No Sample' in the results. If I just converted to zero I would just do:

      if width=. then do width='0';    

But since I need to change it to a character I am unsure what to do.

Thanks

Explanation / Answer

Here' what you can do:

Your SAS column width can either be a numercial or a character. Since you have mentioned that you want a character variable you could do the following:

1. Cast this variable into a new character variable. Lets say "width_char".

Use this in the DATA STEP command of SAS:

width_char= put(width, 7.) ; < convert into character using the PUT function, put can take more arguements>
drop width; <use this line of SAS if you want to drop numerical width>
rename width_char=width; < rename width_char to width>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote