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       
Try cartesian product and do the subtraction
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;It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.
