Hi MBI.
I'm afraid you can only do that programmatically. Here is some sample code : let's say you have a dataset called MyData, and a variable (column) called X.
DATA myDataFilled (DROP = filledX) ;
SET myData ;
RETAIN filledX ; /* keeps the last non-missing value in memory */
IF NOT MISSING(X) THEN filledX = X ; /* fills the new variable with non-missing value */
X = filledX ;
RUN ;
Regards.
Olivier
Hi MBI.
I'm afraid you can only do that programmatically. Here is some sample code : let's say you have a dataset called MyData, and a variable (column) called X.
DATA myDataFilled (DROP = filledX) ;
SET myData ;
RETAIN filledX ; /* keeps the last non-missing value in memory */
IF NOT MISSING(X) THEN filledX = X ; /* fills the new variable with non-missing value */
X = filledX ;
RUN ;
Regards.
Olivier
Excellent
Hello @Olivier
may I ask what if the non missing value does not appear as the first observation? How to fill in the table in the following case?
group | time | value |
1 | Jan | . |
1 | Feb | 10 |
1 | Mar | . |
2 | Jan | . |
2 | Feb | . |
2 | Mar | 20 |
3 | Jan | 30 |
3 | Feb | . |
3 | Mar | . |
4 | Jan | . |
4 | Feb | 40 |
4 | Mar | . |
5 | Jan | 50 |
5 | Feb | . |
5 | Mar | . |
and I want the data to be filled in as follows:
group | time | value |
1 | Jan | 10 |
1 | Feb | 10 |
1 | Mar | 10 |
2 | Jan | 20 |
2 | Feb | 20 |
2 | Mar | 20 |
3 | Jan | 30 |
3 | Feb | 30 |
3 | Mar | 30 |
4 | Jan | 40 |
4 | Feb | 40 |
4 | Mar | 40 |
5 | Jan | 50 |
5 | Feb | 50 |
5 | Mar | 50 |
Thank you!
Hi Nieves,
I am having the same problem right now where the value that I want pasted to all other records within each group is always the last...not the first. Did you ever get a solution to your question?
If so, could you forward that solution to me? I desperately need it.
Thank you!
Just sort your data in reverse order, so the value you want is at the top. Once you've rippled your value, resort into the original sequence.
Tom
AMAZING
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.