DATA Step, Macro, Functions and more

sas subtraction

Reply
Occasional Contributor
Posts: 9

sas subtraction

Dataset one  Dataset two   
lang1  long1  lang2 long2 
221  334       823 567 
456  832      732 346 
563  678     568 235 
444  333     
555  444     
666  555     
777  666     
1002  890     
1560  1021     
1567  8946     
2340  1290     
3460  2230     
       
How to loop through the two datasets in the following fashion and do the subtraction?       
(221-823)     (334-567)  
(221-832)     (334-346)  
(221-568)     (334-235)  
(456-823)      .  
(456-732)     .  
(456-568)     .  
(563-823)     .  
(563-732)     .  
(563-568)     .  
.     .  
.     .  
.     .  
.     .  
.     .  
.     .  
(3460-823)    (2230-567)  
(3460-732)    (2230-346)  
(3460-568)    (2230-235)  
       
Subtraction       

Super User
Posts: 2,066

Re: sas subtraction

Posted in reply to mauri0623

Try cartesian product and do the subtraction

Contributor
Posts: 31

Re: sas subtraction

Posted in reply to mauri0623

something like this should work:

proc sql;
	create table work.want as 
		select lang1
			, lang2
			, lang1-lang2 as lang_diff
			, long1
			, long2
			, long1 - long2 as long_diff
		from work.have1 
		cross join work.have2
		;
quit;
Ask a Question
Discussion stats
  • 2 replies
  • 112 views
  • 2 likes
  • 3 in conversation