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 votefavoriteI 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>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.