How to remove complete observation with all missing values in a scenario of 1000's of observations (in SAS)?

sas
missing_values
data_wrangling

#1

Hi all,
i have dataset…

23 56 . 56
24 . 8 .
2 . . 23
. . . .
. . 4 .

here i wanna remove 4th observation totally from the dataset, which means i dont want complete missing values observations in the datasets.

Regards,
sahil.


#2

@zubairsahil

You can use array to perform this. Look at below codes.

Data sets

Data Test;
Input Var1 Var2 Var3 Var4;
datalines;
23 56 . 56
24 . 8 .
2 . . 23
. . . .
. . 4 .
;
Run;

Delete Records of Missing Values

Data Test2 (Drop = Count i);                    
set test;        
/* Keyword _NUMERIC_ to load all numeric variables  into the NUM array.*/
array check(*) _numeric_;   
count=0; 
do i = 1 to dim(check);           
if not missing(check(i)) then count+1;     
end;   
/* COUNT=0 means all values are missing */
if count=0 then delete; 
run;

Regards,
Sunil


#3

yeah thank you sir it works…
i believe “N” function also works. (not the N), have not tried yet with N


#4

yes dis also works.
data test;
set test;
if n(of var1-var2);
run;

this is the case of non-missing values.