Tuesday, 29 January 2013

How to find out, whether particular data (Keyword) is available in any variable in your entire SAS Dataset?



You want to know, whether particular data (Keyword) is available in any variable in your entire SAS Dataset?

Below small SAS code will search all the observations and variables in your input SAS dataset and creates an new dataset called ‘Found’, which contains the row number and variable name in which it found the specified keyword…



data inputdata;
input var1 $ var2 $ var3 $;
cards;
pavan kumar rao
ramu pavan reddy
vijay chari vikas
pavannn again came
;
run;

data found (keep=rownum varname keyword);
set inputdata;
array google(*) _char_;
keyword=’pavan’;
do i=1 to dim(google);
if index(google(i),strip(keyword)) then do;
rownum=_n_;
varname=vname(google(i));
output;
end;
end;
run;

No comments:

Post a Comment