Hi,
I have this tiny table attached (3 observations) with a lot of variables. I'd like to keep only the variables for which there exists different values between at least 2 observations (or supress variables that have the same values for all the observations). Do you know a simple way to do this ?
The NLEVELS output of PROC FREQ will show you how many distinct values each variable has.
You can use ODS OUTPUT to get the result into a dataset.
ods output nlevels=nlevels;
proc freq data=carross1 nlevel;
tables _all_ / noprint;
run;
You can now pull the list of names that mean you criteria into a macro variable using PROC SQL. Either make a list of the ones to keep or the ones to delete and use the list in a KEEP or DROP statement (or dataset option).
proc sort data=inputdata nodupkey;
by _all_;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.