BookmarkSubscribeRSS Feed
Mathis1
Quartz | Level 8

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 ? 

 

2 REPLIES 2
Tom
Super User Tom
Super User

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).

smantha
Lapis Lazuli | Level 10
proc sort data=inputdata nodupkey;
by _all_;
run;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 425 views
  • 0 likes
  • 3 in conversation