02-01-2012 10:28 AM
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
02-01-2012 11:44 AM
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.
02-01-2012 11:22 AM
It sounds like this is what you are trying to do.
proc sort data=my_data;
by postal_code car_model time_period;
by postal_code car_model;
if first.car_model then keep_deleting='Y';
if car_price=. then do;
if keep_deleting='Y' then delete;
I'm not sure if you need postal_code in the logic or not ... depends on what you are trying to accomplish.
02-02-2012 06:04 PM
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.