BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

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

4 REPLIES 4
art297
Opal | Level 21

Can you provide an example of what your records currently look like and how you want them to look after being manipulated?

podarum
Quartz | Level 8

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.

Astounding
PROC Star

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.

udo_sas
SAS Employee

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

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 806 views
  • 0 likes
  • 4 in conversation