BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

8 REPLIES 8
Reeza
Super User

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

woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

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!

Reeza
Super User

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.

Tom
Super User Tom
Super User

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;

woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

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!!!

LinusH
Tourmaline | Level 20

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
Tom
Super User Tom
Super User

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

;

sas_9
Obsidian | Level 7

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!!!***/

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 8 replies
  • 1981 views
  • 0 likes
  • 5 in conversation