variable in spss is familygrossincome:
0='Unknown or not applicable'
1= 'Less than 20,000'
3= '20,000 to 39,999'
8='40,000 to 59,999'
12='60,000 to 79,999';
When imported, proc contents shows it is numeric. When I run proc freq it displays the levels as text i.e.
Unknown or not applicable
less than 20,000
etc
When I do where statement I have to use numeric value (0, 1, 3, 8 12). I can only tell these are the values by looking at spss I cannot find them in sas
If i make a character copy using familygrossCat= STRIP (PUT(familygrossincome, familygross.) then proc freq only displays 0,1 3, 8, 12)
I guess I have three questions.
1) How do create a categorical variable with the text values not the numbers?
2) If I do copy numbers, how do I get procedures to display the text values (e.g. less than 20,000) instead of numerical value?
3) What is the command to see what the numerical and character values are for a variable? I usually just look at the original spss file
Thank you!
It has not been changed to character and attempts to modify it are likely going to misbehave. When you ran proc contents it should have shown you that the variable has a format associated with it, and likely to be the name of the variable. Which is why reference in Where or IF statements you need the 0, 1 etc.
If you want proc freq to show the 1, 2, 3 values then add a line to the code like:
format familygrossCat best.;
Proc freq by default will use the currently assigned format for any of the variable values.
So I am not sure if this how best to approach it but this is what I was able to do:
proc format;
value familygross
0='Unknown or not applicable'
1= 'Less than 20,000'
3= '20,000 to 39,999'
8='40,000 to 59,999'
12='60,000 to 79,999';
run;
proc freq data=FA2013_7;
tables familygrossincome;
format familygrossincome familygross.;
run;
I still do not know how to display values that have been imported for the variable from spss.
Thank you for your response and help!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.