Hello guys,
please view my output. I want to make my data-set to have only observations that responded yes (1) and No (2) based on COPD . And to delete the observations coded 7 and 9. Here's my code so far
LIBNAME perm 'D:\';
DATA Newsasdata (keep= Alchrc10 Alchrc9 cbrchyr chlev copdev ephev R_Maritl Age_p MracbpI2 sex hypev);
SET perm.nhis2012sampleadult;
RUN;
.
Are you looking for this
LIBNAME perm 'D:\';
DATA Newsasdata (keep= Alchrc10 Alchrc9 cbrchyr chlev copdev ephev R_Maritl Age_p MracbpI2 sex hypev);
SET perm.nhis2012sampleadult;
where copdev not in (7,9);
RUN;
Post the sample of your dataset plz
I've posted the output and the code. I want to delete the observations that answered 7 and 9 from my entire dataset
Are you looking for this
LIBNAME perm 'D:\';
DATA Newsasdata (keep= Alchrc10 Alchrc9 cbrchyr chlev copdev ephev R_Maritl Age_p MracbpI2 sex hypev);
SET perm.nhis2012sampleadult;
where copdev not in (7,9);
RUN;
@ChuksManuel wrote:
Hello guys,
please view my output. I want to make my data-set to have only observations that responded yes (1) and No (2) based on COPD . And to delete the observations coded 7 and 9. Here's my code so far
LIBNAME perm 'D:\';
DATA Newsasdata (keep= Alchrc10 Alchrc9 cbrchyr chlev copdev ephev R_Maritl Age_p MracbpI2 sex hypev);
SET perm.nhis2012sampleadult;
RUN;
You may want to consider creating a new recoded variable with code similar to :
data recode; set have; copd_recode = copd; if copd in (7,9) then call missing(copd_recode); run;
And use the recoded variable.
One reason is suppose you also want to see frequencies of another variable. If you actually remove the records then the counts for the other variables would be affected. By creating another variable with missing then the proc freq (or other procedures) will have the correct number of observations to use with the other variables. If you do something like copd_recode*sex with the recoded variable then their will be indications of missing values but the counts and percentages within the categories would be represented.
And if that data comes from BRFSS then I have seen lots of recodes like that.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.