BookmarkSubscribeRSS Feed
Magaarnico
Calcite | Level 5

I have a dataset with time, bid ask

For example

Time                    Bid               Ask

1/1/2013               2                    1

1/2/2013                .                    2

1/3/2013               3                    4

1/4/2013               .                    3

1/5/2013               .                    2

1/6/2012               4                    1

I want to fill in the mssing values (.) with the last observation

For example at 1/5/2013 under bid it must say 3. Tried to use LOFC and Retain..

But doesent work:/

any one have i code i can use 😃

thx in advance

1 REPLY 1
Ksharp
Super User
data have;
input Time  :mmddyy10.                 Bid               Ask;
format time mmddyy10.;
cards;
1/1/2013               2                    1
1/2/2013                .                    2
1/3/2013               3                    4
1/4/2013               .                    3
1/5/2013               .                    2
1/6/2012               4                    1
;
run;
data want;
 set have;
 retain _bid;
 if not missing(bid) then _bid=bid;
 drop bid;
run;

Ksharp

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!

How to Concatenate Values

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.

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
  • 1 reply
  • 382 views
  • 0 likes
  • 2 in conversation