*********************************************************************** * Program: C:\NHANES\CleanRecode_RecodeMissing.sas * * Proposal: Recode values to missing * ***********************************************************************; libname NH "C:\your_dir"; /*change the name of the directory folder to the location that you saved your downloaded dataset from the sample code and dataset downloads module: for example "c:\nhanes\data"*/ /*Data step to assign refusal, don't know as missing*/ Data demo_BP1; set NH.demo_BP; /*option 1: assign 7,9 as missing one by one*/ if BPQ010 in (7,9) then BPQ010=.; /*option 2: assign 7,9 as missing by group - using array*/ array _rdmiss bpq020 bpq070 bpq080 mcq160b--mcq160f; do over _rdmiss; if _rdmiss in (7, 9) then _rdmiss=.; end; run; /*Check the extent of missing data*/ Proc means data=NH.demo_BP N Nmiss min max; where ridstatr=2 and ridageyr>=20; * interviewed and examined(ridstatr=2), adults age 20+; var BPQ010--BPQ100d MCQ160b--MCQ160f; *blood pressure variables; Title "Check missing, min, max values for numeric variables"; Proc freq data=NH.demo_BP; where ridstatr=2 and ridageyr>=20; table BPQ010--BPQ100d MCQ160b--MCQ160f/list missing; title 'Check frequency distribution for categorical variables'; run;