09-15-2011 09:15 AM
Hi. I have a question that my knowledge of datasteps and arrays can't really handle.
I have some data of the form:
Iden Var1 Var2 Var3 Var4
1 x y
4 x z
What i hope to make clear is that i have different variables, named anumabb2 to anumabb34, that contain non-numeric text.
What i wan't to delete is the row with iden 2, because all that exact one has all empty variable slots.
I hope it makes sense, and i'm thinking it has a simple solution that im too high on coffee to find for myself!
09-15-2011 10:40 AM
Hi ... here's another idea.
if ^missing(cats(of anumabb2-anumabb34));
A generic approac to this question is shown below.
The OPTIONS MISSING=' ' is needed if there are
any numeric variables in your data set since the CATS function will add
a period to the concatenated string of values if the default value of
a period is used.
options missing = ' ';
if ^missing(cats(of _all_));
options missing = '.';
09-15-2011 02:52 PM
select COMPRESS(name)||" is not null" into :COND SEPARATED BY ' OR '
where memname='TEST' AND TYPE='char'
Step 1: i'm selecting all the variables that are character as per the requirement into a macro variable . (Using dictionary)
Step 2: using the macro to be used as my where clause condition. Though it looks like two steps, the first steps doesn't access data but dictionary, hence it doesn't take time.
I'm using where clause instead of if to improve the performance. but it works.
09-15-2011 11:06 PM
Art has already given your answer.
data temp; infile datalines truncover; input (Iden Var1 Var2 Var3 Var4 ) ($) ; datalines; 1 x y 2 3 y 4 x z ; run; %global nvar list; proc sql noprint; select name ,count(name) into : list separated by ',', : nvar from dictionary.columns where libname='WORK' and memname='TEMP' and name like 'Var%'; quit; %put &nvar &list; data temp; set temp; if cmiss(of &list) eq &nvar then delete; run;