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!
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')
;
What are you actually trying to do here? Get all records where any variable is null or missing?
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!
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.
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;
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!!!
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).
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')
;
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!!!***/
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.
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.