This is Your Life… with SAS
Your daily activities, morning to night, are influenced by SAS software in ways that you probably never considered. Learn how SAS makes live better in a typical day. Learn more at http://www.sas.com/news/sascom/dayinlife.html

Source: See more such videos at SASsoftware channel on YouTube.

Drop any variable (Num/Char), if its data is missing in all of the observations…..

%macro DropMissingVars(DS=);
data _null_;
set &ds. (obs=1);
array num_vars[*] _NUMERIC_;
array char_vars[*] _CHARACTER_;
call symputx(‘num_qty’, dim(num_vars));
call symputx(‘char_qty’, dim(char_vars));
run;

data _null_;
set &ds. end=finished;

array num_vars[*] _NUMERIC_;
array char_vars[*] _CHARACTER_;

array num_miss [&num_qty] $ (&num_qty * ‘missing’);
array char_miss [&char_qty] $ (&char_qty * ‘missing’);

length list $ 50;

do i=1 to dim(num_vars);
if num_vars(i) ne . then num_miss(i)=’non-miss’;
end;
do i=1 to dim(char_vars);
if char_vars(i) ne ” then char_miss(i)=’non-miss’;
end;

if finished then do;
do i= 1 to dim(num_vars);
if num_miss(i) = ‘missing’ then list=trim(list)||’ ‘||trim(vname(num_vars(i)));
end;
do i= 1 to dim(char_vars);
if char_miss(i) = ‘missing’ then list=trim(list)||’ ‘||trim(vname(char_vars(i)));
end;
call symput(‘mlist’,list);
end;
run;

data &ds;
set &ds;
drop &mlist;
quit;

%mend DropMissingVars;
%DropMissingVars(DS=work.test);

1. Mouse over tooltip – gives you help right in the program editor window.
2. Autocomplete – start typing a keyword, SAS will offer you code options.

Source: http://blogs.sas.com/

Google your SAS Dataset….

Posted: September 7, 2011 in SAS Tips & Tricks

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;

*Happy Learning!!

Automatic Macro Variable SYSNOBS: Contains the number of observations read from the last data set that was closed by the previous procedure or DATA step.
Macro Function %SYSMACEXIST: Indicates whether there is a macro definition exist in the WORK.SASMACR catalog.
Macro Statement %SYSMACDELETE: Deletes a macro definition from the WORK.SASMACR catalog.
Till SAS 9.2, the alternate code what we used to write is:
proc catalog catalog=work.sasmacr;
delete helloworld.macro;
quit;

More macro debugging with MAUTOCOMPLOC System option: Displays in the SAS log the source location of the autocall macros when the autocall macro is compiled.

For detailed news, please click here:
http://www.sas.com/mailings/camp2007/c22510.html

Whats new in SAS 9.3? Read here:
http://support.sas.com/documentation/cdl/en/whatsnew/64209/HTML/default/viewer.htm#titlepage.htm