## Proc Expand replaces beginning missing values?

Solved
Occasional Contributor
Posts: 9

# Proc Expand replaces beginning missing values?

Hi --

I'd really appreciate help with this question if anyone has any suggestions.

I have a dataset that looks like this --

date Series1 Series2

1980    .        20

1981   .          .

1982   10      15

1983   30      .

1984   25       19

1985   27       22

1986   .          25

1987   .          23

I want to be able to do the following --

a. Replace the two missing values (with zeros) for Series 2 for the years 1981 and 1983 (zero is a valid value for embedded missing values).

b. Replace the two missing values (with zeros) at the end for 1986 and 1987 for Series 1.

But, I DON'T want to replace the missing values for 1980 and 1981 for Series 1 since the series was yet to begin then (so, a zero would not be a valid value).

I've tried using Proc Expand to do it and here's the code --
Proc Expand data =year_ds out = year_ds1;
Id date;
convert series1 series2 / Transformin = (Setmiss 0);
Run;

The documentation says that Proc Expand only replaces embedded missing values i.e., it doesn't change beginning and ending missing values. So, the code above should only replace the embedded missing values for Series 2 (so, it shouldn't change the beginning and ending values for Series 1) but from what I'm seeing, the beginning and ending values (for Series 1) are being replaced with 0s as well  -- so, all missing values in Series 1 and 2 are being replaced with 0s.

Any ideas would be greatly appreciated!

Thanks.

Accepted Solutions
Solution
‎08-11-2016 02:22 PM
Posts: 4,934

## Re: Proc Expand replaces beginning missing values?

try:

``````
Proc Expand data =year_ds out = year_ds1 method=none;
Id date;
convert series1 series2 / Transformout = (setembedded (. 0) setright (. 0));
Run;``````
PG

All Replies
Solution
‎08-11-2016 02:22 PM
Posts: 4,934

## Re: Proc Expand replaces beginning missing values?

try:

``````
Proc Expand data =year_ds out = year_ds1 method=none;
Id date;
convert series1 series2 / Transformout = (setembedded (. 0) setright (. 0));
Run;``````
PG
Occasional Contributor
Posts: 9

## Re: Proc Expand replaces beginning missing values?

Thanks so much -- that works!
☑ This topic is solved.