BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tim-hahn
Fluorite | Level 6

Hi SAS users,

 

thank you for taking your time. 

I have the dataset "Data1", with a structure like this:

2.PNG

 

And I have the Dataset "Sum1", which looks like this: 

 

3.PNG

 

I would like to merge those two so that for every row in data set "Data1" the corresponding values of variables sum1 and n from Dataset "Sum1" show up if the Jahr=Jahr and if ICBSUC=ICBSUC

 

So for example for every observation in data set "Data1" which in from Jahr 2010 and has an industry code ICBSUC of 10101010 the value in the variable sum1 should be 1.173... and the value in variable n should be 19. 

 

my current code looks like this: 

 
proc sort data=work.Data1;
by ICBSUC;
run;
 
proc summary data=Data1 nway;
    class  icbsuc Jahr;
    var KehrwertM;
    output out=sum1 sum=sum1 n=n;
run;
 
data Data2;
    merge Data1 sum1 (in =in2);
    by Jahr icbsuc;
    if in2;
run;
 
 
thank you for your help! 

 

 

 

 

  

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

I believe the code what you wrote is correct, a minor update to include if in1 and in2 as below

 

data Data2;
    merge Data1(in=in1) sum1 (in =in2);
    by Jahr icbsuc;
    if in1 and in2;
run;

 

 

Thanks,
Jag

View solution in original post

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

I believe the code what you wrote is correct, a minor update to include if in1 and in2 as below

 

data Data2;
    merge Data1(in=in1) sum1 (in =in2);
    by Jahr icbsuc;
    if in1 and in2;
run;

 

 

Thanks,
Jag
smantha
Lapis Lazuli | Level 10
proc sort data=work.Data1;
by ICBSUC Jahr;
run;
 
proc summary data=Data1 nway;
    class  icbsuc Jahr;
    var KehrwertM;
    output out=sum1 sum=sum1 n=n;
run;
 
data Data2;
    merge Data1 sum1 (in =in2);
    by icbsuc Jahr;
    if in2;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 2 replies
  • 380 views
  • 1 like
  • 3 in conversation