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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.