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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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