Hi, is there a way to delete leading missing values from a dataset, with by groupings. So I have a large dataset by postal codes and car prices, and car models. certain car models werent built until certain years while others go way back.. I don't want to delete all missing since I need the missing values in between that I just don't have any prices for. Just the leading missing whenever they had happend for each model. thanks
Can you provide an example of what your records currently look like and how you want them to look after being manipulated?
Hi Art,
I just realized that if I wanted to keep all variables in the same dataset, then the oldest value is the one that belongs to the first non-missing date. All the others that are also in the dataset will have a missing value (if they don't have any data) starting from that same date.
podarum,
It sounds like this is what you are trying to do.
proc sort data=my_data;
by postal_code car_model time_period;
run;
data remove_missings;
set my_data;
by postal_code car_model;
retain keep_deleting;
if first.car_model then keep_deleting='Y';
if car_price=. then do;
if keep_deleting='Y' then delete;
end;
else keep_deleting='N';
drop keep_deleting;
run;
I'm not sure if you need postal_code in the logic or not ... depends on what you are trying to accomplish.
Good luck.
Hello -
I might be wrong, but this question seems to be related to your post: http://communities.sas.com/message/114872#114872
Again I believe that PROC TIMESERIES (of SAS/ETS) could be of interest, since the start date variable in the OUTSUM data set tells you when the first nonmissing observation per BY group occurred.
Then it should be easy to delete these observations from your original data set.
Hope this makes sense.
Regards,
Udo
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.