BookmarkSubscribeRSS Feed
Squack
Calcite | Level 5

Good morning, I am writing to illustrate a problem that I just can not solve.

this is the data set in question (see attachment). 

 

As you can see, the Data variable has missing values, and I should fill in those values by taking what is above.
For example, if the date corresponds to June 30 in the first line, then also the next two lines must contain June 30th.

 

I am aware that using the LAG1 and LAG2 function I could solve the problem (as I did in SAS base 9.4). I would like to be able to reproduce this in SAS Data Integration, but I have many difficulties.
Could I kindly have any suggestions?

 

Thank you

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Lag will not work there, nor will it work that way in base SAS.  What you would do in Base is retain a value, then populate the other on that if its missing, e.g

data want;
  set have;
  retain lst_date;
  if date ne . then lst_date=date;
  else date=lst_date;
run;
Squack
Calcite | Level 5

First of all, I thank you for the help you are giving me! 🙂

Ok, I'll try this code in SAS base but what you say makes sense.

Can you help me in Data Integration? More than anything else I would like to understand what nodes to use to reproduce this code...

RW9
Diamond | Level 26 RW9
Diamond | Level 26

I am afraid I know nothing about DIS, perhaps someone else from the community will be able to assist.

Squack
Calcite | Level 5
Thanks anyway for answering for SAS 9.4 🙂
LinusH
Tourmaline | Level 20

For DI Studio, you need to create a User Written code transformation.

Or if you think you can write reusable code, a User Written Transformation.

If you need further help, specify what you need help with.

Data never sleeps
Squack
Calcite | Level 5

Thanks for the reply LinusH!
I had also thought about using the User Written code transformation...
It is very recently that I use DI and this particular node creates many problems ..
The main thing is that it almost never finds the dataset I'm using.
Maybe I'm wrong ...
Can you tell me the correct procedure to use it?

LinusH
Tourmaline | Level 20

Can you clarify what you mean by "it almost never finds the data set I'm using"?

 

Writing efficient and roubust DI code is craftsmanship, and there's papers and documentation available.

Short, you need to use the DI Studio macro variables for input and output data set, that is the baseline. In this way, any linked table will be automatically "found", given that the rest of the job and the environment as such is stable and maintained in the correct way.

Data never sleeps

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1827 views
  • 1 like
  • 3 in conversation