How can i delete the missing observations.
Ex:
user class score
1 123 90
2 143 89
3 143 12
4 . .
5 . .
i do not want observation 4 and 5 as the variables are missing.
hi try this,
data exp1;
input user class score ;
if missing(class) and missing(score) then delete;
datalines;
1 123 90
2 143 89
3 143 12
4 . .
5 . .
;
run;
Regards
ALLU
I want to take 80 percent of total unique id as seperate dataset and the other 20 percent as seperate.
Hi,
Try the following SAS Code...
/*Remove the duplicates from IDs*/
proc sort nodupkey data = test;
by id;
run;
/*Calculating Percentage*/
data _null;
set test end = eof;
if eof then do;
totobs = _n_;
percent = round((80*totobs)/100);
call symput('_80_percent',percent);
end;
run;
/*Separating IDs based on Percentges*/
data data_80 data_20;
set test;
if _n_ LE &_80_percent. then output data_80;
else output data_20;
run;
Hope it meets the requirement and please confirm that you split the IDs on the basis of PERCENTAGE not the PERCENTILE...If it is the later then this code wont work...
Thanks,
Urvish
Should the 80/20 split all non-missing rows, or be based on distinct ID (with non-missing data) ?
assuming an ID might appear more than once
Is the selection supposed to be random 20%
peterC
hi,
You can use arrays as well to delete the missing observations.
data have;
input user class score;
cards;
1 123 90
2 143 89
3 143 12
4 . .
5 . .
;
run;
data want;
set have;
array mis(*) _numeric_;
do i=1 to dim(mis);
if mis(i)=. then delete;
end;
run;
Thanks,
Jagadish
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.