BookmarkSubscribeRSS Feed
WilliamB
Obsidian | Level 7

Hello,

I have 2 tables, the first in T and the second in T-1.
I would like to gather these 2 tables, and calculate the variation rates of variation P and C.

 

Table T:

IdlibP_tC_t
8157ABU DHABI INVESTMENT AUTHORITY65901635,611323542,3
21504ROYAUME DES PAYS BAS - KINGDOM OF THE NETHERLANDS148436781,60
22484REPUBLIQUE DE COTE D'IVOIRE11713154,548452866,03
92137REPUBLIQUE POPULAIRE DE CHINE29409445,090
93043UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND14520
97827GOUVERNEMENT DU JAPON - JAPAN1516

303,2

 

 

 

Table T-1

 

IdlibP_t1C_t1
8157ABU DHABI INVESTMENT AUTHORITY73594883,71478050,48
21504ROYAUME DES PAYS BAS - KINGDOM OF THE NETHERLANDS135298880,50
83590THE COMMONWEALTH OF AUSTRALIA AUSTRALIA202900
89761CANADA GOUVERNEMENT3610
93043UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND43510
103335REPUBLIQUE DE LITHUANIE519750001104323,66

 

Here's what I want:

IdlibP_tC_tP_t_1C_t_1Variation PVariation C
8157ABU DHABI INVESTMENT AUTHORITY65901635,611323542,373594883,71478050,48-7693248,1-154508,18
21504ROYAUME DES PAYS BAS - KINGDOM OF THE NETHERLANDS148436781,60135298880,5013137901,20
22484REPUBLIQUE DE COTE D'IVOIRE11713154,548452866,030011713154,58452866,03
92137REPUBLIQUE POPULAIRE DE CHINE29409445,0900029409445,10
93043UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND1452043510-28990
97827GOUVERNEMENT DU JAPON - JAPAN1516303,2001516303,2
83590THE COMMONWEALTH OF AUSTRALIA AUSTRALIA00202900-202900
89761CANADA GOUVERNEMENT003610-3610
103335REPUBLIQUE DE LITHUANIE00519750001104323,66-51975000-1104323,7

 

 


Thanks a lot for your help .



2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post test data in the form of a datastep.  As such this is just an example:

proc sql;
  select  a.*,
          b.*,
          b.p_t1-a.p_t as variationp,
          b.c_t1-a.c_t as variationc
  from    tablet a
  full join tablet1 b
  in      a.id=b.id
  and     a.lib=b.lib;
quit;
SuryaKiran
Meteorite | Level 14

You need to be more specific on the values you have. Your values are like -->65901635,61 is this a single values or two values separated by comma? If they were two values then what was your logic for calculating -7693248,1 How did you get that one there?

 

Please be more specific and provide your sample data in the form of a data step.

Thanks,
Suryakiran

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 576 views
  • 0 likes
  • 3 in conversation