checking null

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 328
Accepted Solution

checking null

Hi all -

i need help and wonder what is the best way to check null values in sas datasets for all variables? and if exist then create index variable for it and then may be use Where statement to pull out...

Thanks!


Accepted Solutions
Solution
‎01-14-2014 09:37 AM
Super User
Super User
Posts: 6,500

Re: checking null

SAS will attempt to use the index if it is available.  You can set option MSGLEVEL=I  (that's the letter i for information) to have SAS report index usage.

Your WHERE clause syntax is wrong.

where (age=20 or age=50)

   and (sex='m')

;

View solution in original post


All Replies
Super User
Posts: 17,837

Re: checking null

What are you actually trying to do here? Get all records where any variable is null or missing?

Super Contributor
Super Contributor
Posts: 328

Re: checking null

I am sorry Reeza i am new at SAS so sometime i don't know how to explain it...BUT

i want get records for any null value in variable and then create index for that variable...

thanks!

Super User
Posts: 17,837

Re: checking null

Post some sample data and sample output please. Also clarify what you mean by index.

I could guess but if I was wrong this whole thing would repeat, so I'd rather not.

Super User
Super User
Posts: 6,500

Re: checking null

If you want to find the observations that have missing values for a particular variable then you can use the WHERE statement. You can use it in any PROC.

proc means data=have ;

  where age=. ;

  var ht wt ;

run;

Super Contributor
Super Contributor
Posts: 328

Re: checking null

Hi guys - i think i can do this and it will run query fast from bigger data....

proc dataset library=woo;

       modify=test /*dataset*/;

       index create age;

       index create sex;

quit;

data xyz;

    set test;

    where age=20 or 50 and sex='m';

run;

Thanks!!!

Super User
Posts: 5,257

Re: checking null

Not following you, now you are not testing for null....?

Besides, I think at least the Base engine will have problems optimize (use the index) your example query.

Creating a composite index using the SPDE engine could work (not sure).

Data never sleeps
Solution
‎01-14-2014 09:37 AM
Super User
Super User
Posts: 6,500

Re: checking null

SAS will attempt to use the index if it is available.  You can set option MSGLEVEL=I  (that's the letter i for information) to have SAS report index usage.

Your WHERE clause syntax is wrong.

where (age=20 or age=50)

   and (sex='m')

;

Regular Contributor
Posts: 220

Re: checking null

you can try this i guess....

/*this way you will get missing & not missing value for all variables*/

proc format;

       value $missfmt  ' '  ='missing' other=' not missing';

       value missfmt    .  = 'missing' other='not missing';

run;

proc format data= work.test; /*your test dataset goes here*/

       format _char_ $missfmt. ;

       table _char_ /missing nocum nopercent missprint;

       format _numeric_ missfmt.;

       table _numeric_/missing nocum nopercent missprint;

run;

/****gd lk!!!***/

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 451 views
  • 0 likes
  • 5 in conversation