BookmarkSubscribeRSS Feed
arslan
Calcite | Level 5

hallo,

how kann i find or delete if the any Variable in a table have the same value?
for Ex:
if the var1 have only  value "test" then  i dont need that Variable.


I have 1478 Variable. i can not look at every Variable wiht Prog tabulate or freq.

best Regards
Celal

7 REPLIES 7
data_null__
Jade | Level 19

Consider this proc freq.   Depending on your data this may be "too much".  If you have variables that you know have more than one level you could drop them from consideration.  data=sashelp.heart(drop=.......);

ods select nlevels;
ods output nlevels=nlevels;
proc freq data=sashelp.heart nlevels;
  
run;
ods select all;
arslan
Calcite | Level 5

Thanks but there is no error message:

ERROR: The SAS System stopped processing this step because of insufficient memory

Do you know another way? or with macro?

Thanks a lot

data_null__
Jade | Level 19

I suspected that, don't do so many variables at once and or drop any you know do no need to be tested.

Astounding
PROC Star

For numeric variables, it would be possible to use PROC MEANS instead of PROC FREQ.  The program could compare the MIN to the MAX for each variable, to see whether they differ.  (That would not identify variables that are always either missing or some other constant value.)  The difficultly with that approach is that it gets a little complex.  A simpler way would be to have PROC MEANS compute the range:

proc means data=have noprint;

  var _numeric_;

  output out=stats (drop=_freq_ _type_) range=;

run;

The values in the output data set should be easy to parse in a DATA step to figure out which values change.  The only complication is that the DATA step would need to use an array with the VNAME function to determine the original variable name.

That approach would let you limit PROC FREQ to handling just the character variables ... possibly with enough memory to do the job.

Good luck.

data_null__
Jade | Level 19

I think this SAS-L thread address the subject well.

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0712C&L=sas-l&D=0&P=42815

It includes participation from some real SAS programming "heavy hitters" and one not so much (me).

Haikuo
Onyx | Level 15

Thanks, DN. That was a heck of thread. Many famous names. Are they all retired or some? Don't see them often on SAS-L anymore.

data_null__
Jade | Level 19

Not much going on on SAS-L at all these days, although most of the participants in that thread are still around from time to time.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 7 replies
  • 1329 views
  • 2 likes
  • 4 in conversation