BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
anitapamu2
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

3 REPLIES 3
Patrick
Opal | Level 21

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;

 

anitapamu2
Calcite | Level 5

Hereafter It will not repeat and Thank you!

 

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

Astounding
PROC Star

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;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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
  • 3 replies
  • 1447 views
  • 0 likes
  • 3 in conversation