Hi, I have a dataset with around 520 variable with many missing values. I want to delete variables with >90% missing values (I dont want to impute). Is there any macro or anything else to do it? I tried ChatGPT, but I got an error that GPT could not solve. Here is GPTcode: /* Step 1: Calculate the percentage of missing values for each variable */ ods output onewayfreqs=missing; proc freq data=dxccsr_transposed; tables _all_ / missing; run; /* Step 2: Identify variables with 90% or more missing values */ data _null_; set missing end=lastobs; if _n_ = 1 then call symputx('numvars',_nobs_); array pctmiss(*) _:; array vars(*) $ _CHARACTER_; do i = 1 to dim(pctmiss); if pctmiss(i) >= 90 then vars(i) = scan(vlabel(pctmiss(i)), 1, ' '); end; if lastobs then call symputx('delvars',catx(' ', of vars(*))); run; /* Step 3: Define a macro to drop variables */ %macro dropvars; data dxccsr_transposed(drop=&delvars); set dxccsr_transposed; run; %mend; /* Step 4: Call the macro to drop variables */ %dropvars; The log error: NOTE: Line generated by the macro variable "DELVARS". 1 Table DXCCSR_EAR006 3 - 214 23 ERROR 214-322: Variable name 3 is not valid. ERROR 23-7: Invalid value for the DROP option. Thanks
... View more