DATA Step, Macro, Functions and more

MERGING DO LOOP

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

MERGING DO LOOP

[ Edited ]

Data one; input var1 $;

datalines;

scan

MRI

;run;

Data two; input res1 res2;

datalines;

10

45

13

56

; run;

 

OUTPUT: IN ONE DATASET

Var1 res1 res2

scan 10 45

scan 13 56

MRI 10 45

MRI 13 56


Accepted Solutions
Solution
‎10-15-2015 07:43 AM
Super User
Posts: 5,085

Re: MERGING DO LOOP

The SQL solution already posted is easier, but for a DATA step:

 

data want;

   set one;

   do _n_=1 to _nobs_;

      set two point=_n_ nobs=_nobs_;

      output;

   end;

run;

 

View solution in original post


All Replies
Respected Advisor
Posts: 3,896

Re: MERGING DO LOOP

[ Edited ]

Please provide valid and tested SAS syntax creating DATA ONE and DATA TWO.

 

Untested (as I didn't feel like fixing the data steps)

proc sql;
  create table want as
  select *
  from one,two
  ;
quit;

 

Contributor
Posts: 34

Re: MERGING DO LOOP

[ Edited ]

Hereafter It will not repeat and Thank you!

 

Can you please help out In Data Step Method ...for the same Problem

Solution
‎10-15-2015 07:43 AM
Super User
Posts: 5,085

Re: MERGING DO LOOP

The SQL solution already posted is easier, but for a DATA step:

 

data want;

   set one;

   do _n_=1 to _nobs_;

      set two point=_n_ nobs=_nobs_;

      output;

   end;

run;

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 242 views
  • 0 likes
  • 3 in conversation