BookmarkSubscribeRSS Feed
mauri0623
Quartz | Level 8

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       

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Try cartesian product and do the subtraction

Urban_Science
Quartz | Level 8

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 958 views
  • 2 likes
  • 3 in conversation