BookmarkSubscribeRSS Feed
Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

Thanks guys

Haikuo
Onyx | Level 15

Question couldn't more vague. "using value of adjacent coulmn as refernce"

1. I assume it is actually adjacent rows you are looking at, not column, from your context. But I could be wrong.

2. Adjacent where? which direction? from top down or from bottom up?

3. Reference how? how many values you take into consideration? straight copy  or do something else, such as mean?

Haikuo

Astounding
PROC Star

Perhaps simplest:

data want;

   set have;

   if column1 > ' ' then last_column1 = column1;

   else column1 = last_column1;

   retain last_column1;

   if column2 > . then last_column2 = column2;

   else column2 = last_column2;

   retain last_column2;

   drop last_column1 last_column2;

run;

I'm hoping that this "simplest" approach is actually what you are looking for ... each variable can operate independently of the other.  So if column2 is missing for the first observation having column1=B, it is OK to use a column2 value from column1=A.

Good luck.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 17 replies
  • 4010 views
  • 3 likes
  • 7 in conversation