Dear all,
I currently have a huge dataset which looks like this:
Value 1 | value 2 | Value 3 | Value 4 | Value 5 |
OK | OK | NAME1 | . | OK |
OK | OK | NAME2 | Value2 | OK |
OK | OK | Value1 | OK | |
OK | OK | NAME2 | . | OK |
OK | OK | NAME3 | Value3 | OK |
OK | OK | NAME3 | Value3 | OK |
OK | OK | NAME1 | Value1 | OK |
OK | OK | NAME2 | . | OK |
... | ... | ... | ... | ... |
OK | OK | NAME3 | Value3 | OK |
In the end I would like to have something like this:
Value 1 | value 2 | Value 3 | Value 4 | Value 5 |
OK | OK | NAME1 | Value1 | OK |
OK | OK | NAME2 | Value2 | OK |
OK | OK | Value1 | OK | |
OK | OK | NAME2 | Value2 | OK |
OK | OK | NAME3 | Value3 | OK |
OK | OK | NAME3 | Value3 | OK |
OK | OK | NAME1 | Value1 | OK |
OK | OK | NAME2 | Value2 | OK |
... | ... | ... | ... | ... |
OK | OK | NAME3 | Value3 | OK |
I'm currently struggling with the code for this:
I have already the following datastep:
data &outlib..&outdsn.;
Set &outlib..&outdsn;
if missing (value_4) and not missing (value_3) then
do i=1 %to &vars_N.;
do until (not missing(value_4));
but then nothing works further.
Can anyone help me out?
Thanks a lot in advance.
Frederik
Post test data in the form of a datastep in a code window!!
As such I am not typing that in. Why should the third row be used to populate the first one? I can see no logical reason. Post something which actually reflects the problem. Now at a guess, what you can do is to first create a distinct list of Name + Value pairs which are not missing, then merge that back onto the data e.g:
proc sort data=have out=inter (rename=(value4=rep)) nodupkey; by value3 value4; where value3 ne "" and value4 ne ""; run; data want; merge have inter; by value3; if value4="" then value4=rep; run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.