BookmarkSubscribeRSS Feed
Freddy662
Calcite | Level 5

Dear all,

 

I currently have a huge dataset which looks like this:

 

Value 1value 2 Value 3Value 4Value 5
OKOKNAME1.OK
OKOKNAME2Value2OK
OKOK Value1OK
OKOKNAME2.OK
OKOKNAME3Value3OK
OKOKNAME3Value3OK
OKOKNAME1Value1OK
OKOKNAME2.OK
...............
OKOKNAME3Value3OK

 

In the end I would like to have something like this:

Value 1value 2 Value 3Value 4Value 5
OKOKNAME1Value1OK
OKOKNAME2Value2OK
OKOK Value1OK
OKOKNAME2Value2OK
OKOKNAME3Value3OK
OKOKNAME3Value3OK
OKOKNAME1Value1OK
OKOKNAME2Value2OK
...............
OKOKNAME3Value3OK

 

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

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 594 views
  • 0 likes
  • 2 in conversation