BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bluesky
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

try:

 


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

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

try:

 


Proc Expand data =year_ds out = year_ds1 method=none;
Id date;
convert series1 series2 / Transformout = (setembedded (. 0) setright (. 0));
Run;
PG
bluesky
Fluorite | Level 6
Thanks so much -- that works!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

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.

Discussion stats
  • 2 replies
  • 1190 views
  • 1 like
  • 2 in conversation