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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.