06-23-2012 02:26 AM
I have a categorical variable, labelled 0-9. I need to delete certain values so I can run a CHISQ.
This is what I'm trying, but with no luck:
DATA mn.lahrt; *my dataset*
SET IHD_DX; *the variable name*
IF IHD_DX = 0 THEN delete;
IF IHD_DX = 8 and 9 Then delete;
I need to keep categories 1-7 only (which are further split in only two categories).
06-23-2012 02:27 PM
Your language is very confused. Sounds to me like you have a variable named IHD_DX in a dataset named MN.LAHRT.
You would not normally want to overwrite your input dataset as in your example code. In fact to limit data you can just use a WHERE statement in your procedure calls.
proc freq data=mn.lahrt ;
where 1<= idh_dx <= 7 ;
tables idh_dx / chisq ;
I am not sure what you mean by "labeled" values. Is it possible that the actual values in IDH_DX variable are something other than the values 0,1,....9 ? Do you have a format attached?
You can also use formats to temporarily regroup you data for a PROC FREQ call. For example if you want to regroup your values into two groups you might use something like:
proc format ;
value group 1-7 = 'VALID' other='INVALID';
proc freq data=mn.lahrt;
format idh_dx group.;