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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.