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.
try:
Proc Expand data =year_ds out = year_ds1 method=none;
Id date;
convert series1 series2 / Transformout = (setembedded (. 0) setright (. 0));
Run;
try:
Proc Expand data =year_ds out = year_ds1 method=none;
Id date;
convert series1 series2 / Transformout = (setembedded (. 0) setright (. 0));
Run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.