vassilisef
Technical User
Hey,
I am having a SAS data set of the form:
Name P VO
ABC 4.80 1000
ABC 4.80 .
ABC 4.80 .
EFG 6.40 2000
EFG 6.40 .
EFG 6.40 .
but of course, with hundreds of names and thousands of observations (P & VO) for each name value.
My objective is to "clean" the tail of each name group for which the VO is a missing value. Namely, using just one Data step i would like to end up with an new set :
ABC 4.80 1000
EFG 6.40 2000
Naturally, if i use the following code:
I will only get the Very last observation from each namegroup curtailed. Is there a way to make the 2nd iteration of the loop to apply to the dataset resulting from the 1st iteration (i.e. to a new dataset resulting after the 1st iteration has already deleted the last obs per name) ??
Thanks in advance,
Vassilis
I am having a SAS data set of the form:
Name P VO
ABC 4.80 1000
ABC 4.80 .
ABC 4.80 .
EFG 6.40 2000
EFG 6.40 .
EFG 6.40 .
but of course, with hundreds of names and thousands of observations (P & VO) for each name value.
My objective is to "clean" the tail of each name group for which the VO is a missing value. Namely, using just one Data step i would like to end up with an new set :
ABC 4.80 1000
EFG 6.40 2000
Naturally, if i use the following code:
Code:
data work.inputobserv;
infile datalines dlm=',';
input name:$3. P:4.2 VO:4.;
datalines;
ABC,4.80,1000
ABC,4.80,.
ABC,4.80,.
EFG,6.40,2000
EFG,6.40,.
EFG,6.40,.
;
run;
data work.cleantail;
set inputobserv;
by name;
do;
if (last.name and VO=.) then delete;
end;
run;
I will only get the Very last observation from each namegroup curtailed. Is there a way to make the 2nd iteration of the loop to apply to the dataset resulting from the 1st iteration (i.e. to a new dataset resulting after the 1st iteration has already deleted the last obs per name) ??
Thanks in advance,
Vassilis