<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Compute ratio from two database for a given date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/919802#M362298</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;I haven't checked for quality. Just did some quick coding. Please check if this is what you need ...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data height;
infile cards delimiter='|';
format date_: date9.;
input ID date_t1:date9. date_t2:date9. date_t3:date9. date_t4:date9. 
      height_t1 height_t2 height_t3 height_t4;
cards;
1 | 2nov23 |  1jan24 |  3feb24 | 15apr24 |  150  | 152 | 150  | 151
2 |12dec23 | 18feb24 |  5apr24 | 19jun24 |  170  | 171 | 170  | 170
3 | 4oct23 | 15feb24 | 16apr24 | 7jun24  |  180  | 178 | 179  | 182
;
run;
data weight;
infile cards delimiter='|';
format date_: date9.;
input ID date_t1:date9. date_t2:date9. date_t3:date9. date_t4:date9. 
      weight_t1 weight_t2 weight_t3 weight_t4;
cards;
1 | 2nov23 |  3feb24 | 15apr24 | 7oct24  |    50 |  52 |  57  |  60
2 |12dec23 | 18feb24 | 19jun24 | 5jul24  |    80 |  74 |  78  |  69
3 | 4oct23 | 15feb24 | 16apr24 | 7jun24  |   102 | 103 | 104  | 102
;
run;
data height_tp(drop=i date_t: height_t:);
 set height;
 array datum(4)   date_t1 - date_t4;
 array hh(4)    height_t1 - height_t4;
 do i=1 to dim(datum);
  date=datum(i);
  height=hh(i);
  output;
 end;
 format date date9.;
run;
data weight_tp(drop=i date_t: weight_t:);
 set weight;
 array datum(4)   date_t1 - date_t4;
 array ww(4)    weight_t1 - weight_t4;
 do i=1 to dim(datum);
  date=datum(i);
  weight=ww(i);
  output;
 end;
 format date date9.;
run;

data want;
 merge height_tp(in=hh) weight_tp(in=ww);
 by ID date;
 if NOT (hh and ww) then delete;
 height_div_weight_ratio=height/weight;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Mon, 11 Mar 2024 17:12:35 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2024-03-11T17:12:35Z</dc:date>
    <item>
      <title>Compute ratio from two database for a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/919542#M362186</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have two databases.&lt;BR /&gt;The first one contains an ID, several "date" variables (date_t1, date_t2, etc.) and several "height" variables (height_t1, height_t2, etc.). For example, date_t1 corresponds to the measurement date of the height specified in height_t1, and the same for t2, and so on.&lt;BR /&gt;The second contains an ID, several "date" variables (date_t1, date_t2, etc.) and several "weight" variables (weight_t1, weight_t2, etc.). For example, date_t1 corresponds to the date of measurement of the weight specified in weight_t1, idem for t2, and so on.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here's what the databases look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st database :&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; date_t1&amp;nbsp;&amp;nbsp; date_t2&amp;nbsp;&amp;nbsp; date_t3&amp;nbsp;&amp;nbsp; date_t4&amp;nbsp;&amp;nbsp; height_t1&amp;nbsp;&amp;nbsp; height_t2&amp;nbsp;&amp;nbsp; height_t3&amp;nbsp; height_t4&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; &amp;nbsp; 2nov23&amp;nbsp;&amp;nbsp; 1jan24 &amp;nbsp; &amp;nbsp; 3feb24 &amp;nbsp; 15apr24 &amp;nbsp; &amp;nbsp; &amp;nbsp; 150 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 152 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 150&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 151&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; 12dec23&amp;nbsp; 18feb24&amp;nbsp;&amp;nbsp; 5apr24 &amp;nbsp; 19jun24 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 170 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 171 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 170&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 170&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp; &amp;nbsp; 4oct23&amp;nbsp;&amp;nbsp; 15feb24 &amp;nbsp; 16apr24&amp;nbsp;&amp;nbsp; 7jun24&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 180 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 178 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 179&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 182&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2nd database :&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; date_t1&amp;nbsp;&amp;nbsp; date_t2&amp;nbsp;&amp;nbsp; date_t3&amp;nbsp;&amp;nbsp; date_t4&amp;nbsp;&amp;nbsp; weight_t1&amp;nbsp;&amp;nbsp; weight_t2&amp;nbsp;&amp;nbsp; weight_t3&amp;nbsp; weight_t4&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; &amp;nbsp; 2nov23&amp;nbsp;&amp;nbsp; 3feb24 &amp;nbsp; 15apr24 &amp;nbsp; 7oct24&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 52 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 57 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 60&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; 12dec23&amp;nbsp; 18feb24&amp;nbsp;&amp;nbsp; 19jun24&amp;nbsp;&amp;nbsp; 5jul24 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 80&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 74 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 78 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 69&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp; &amp;nbsp; 4oct23&amp;nbsp;&amp;nbsp; 15feb24 &amp;nbsp; 16apr24&amp;nbsp;&amp;nbsp; 7jun24&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 102 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 103 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 104 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; 102&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I want to calculate the height/weight ratio from these two databases for a given date. The peculiarity is that the values of the variable "dates" in the first database don't necessarily correspond to the values of the variable "dates" in the second database. For example, date_t3 in the first database corresponds to date_t2 in the second database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me to solve this problem? To get a table where there would be only height and weight measurements taken on the same date? (date_t2 would be the same for height and weight, the same for date_t3, etc.).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Florian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2024 19:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/919542#M362186</guid>
      <dc:creator>FlorianM</dc:creator>
      <dc:date>2024-03-08T19:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Compute ratio from two database for a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/919802#M362298</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I haven't checked for quality. Just did some quick coding. Please check if this is what you need ...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data height;
infile cards delimiter='|';
format date_: date9.;
input ID date_t1:date9. date_t2:date9. date_t3:date9. date_t4:date9. 
      height_t1 height_t2 height_t3 height_t4;
cards;
1 | 2nov23 |  1jan24 |  3feb24 | 15apr24 |  150  | 152 | 150  | 151
2 |12dec23 | 18feb24 |  5apr24 | 19jun24 |  170  | 171 | 170  | 170
3 | 4oct23 | 15feb24 | 16apr24 | 7jun24  |  180  | 178 | 179  | 182
;
run;
data weight;
infile cards delimiter='|';
format date_: date9.;
input ID date_t1:date9. date_t2:date9. date_t3:date9. date_t4:date9. 
      weight_t1 weight_t2 weight_t3 weight_t4;
cards;
1 | 2nov23 |  3feb24 | 15apr24 | 7oct24  |    50 |  52 |  57  |  60
2 |12dec23 | 18feb24 | 19jun24 | 5jul24  |    80 |  74 |  78  |  69
3 | 4oct23 | 15feb24 | 16apr24 | 7jun24  |   102 | 103 | 104  | 102
;
run;
data height_tp(drop=i date_t: height_t:);
 set height;
 array datum(4)   date_t1 - date_t4;
 array hh(4)    height_t1 - height_t4;
 do i=1 to dim(datum);
  date=datum(i);
  height=hh(i);
  output;
 end;
 format date date9.;
run;
data weight_tp(drop=i date_t: weight_t:);
 set weight;
 array datum(4)   date_t1 - date_t4;
 array ww(4)    weight_t1 - weight_t4;
 do i=1 to dim(datum);
  date=datum(i);
  weight=ww(i);
  output;
 end;
 format date date9.;
run;

data want;
 merge height_tp(in=hh) weight_tp(in=ww);
 by ID date;
 if NOT (hh and ww) then delete;
 height_div_weight_ratio=height/weight;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2024 17:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/919802#M362298</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2024-03-11T17:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compute ratio from two database for a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/919809#M362300</link>
      <description>&lt;P&gt;Sorry, ... something wrong with (in)formats of the dates.&lt;BR /&gt;I think this is better:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data height;
infile cards delimiter='|';
informat date_t1 date_t2 date_t3 date_t4 date9.;
format   date_t: date9.;
input ID date_t1 date_t2 date_t3 date_t4 
      height_t1 height_t2 height_t3 height_t4;
cards;
1 | 2nov2023 |  1jan2024 |  3feb2024 | 15apr2024 |  150  | 152 | 150  | 151
2 |12dec2023 | 18feb2024 |  5apr2024 | 19jun2024 |  170  | 171 | 170  | 170
3 | 4oct2023 | 15feb2024 | 16apr2024 |  7jun2024 |  180  | 178 | 179  | 182
;
run;
data weight;
infile cards delimiter='|';
informat date_t1 date_t2 date_t3 date_t4 date9.;
format   date_t: date9.;
input ID date_t1 date_t2 date_t3 date_t4 
      weight_t1 weight_t2 weight_t3 weight_t4;
cards;
1 | 2nov2023 |  3feb2024 | 15apr2024 | 7oct2024  |    50 |  52 |  57  |  60
2 |12dec2023 | 18feb2024 | 19jun2024 | 5jul2024  |    80 |  74 |  78  |  69
3 | 4oct2023 | 15feb2024 | 16apr2024 | 7jun2024  |   102 | 103 | 104  | 102
;
run;
data height_tp(drop=i date_t: height_t:);
 set height;
 array datum(4)   date_t1 - date_t4;
 array hh(4)    height_t1 - height_t4;
 do i=1 to dim(datum);
  date=datum(i);
  height=hh(i);
  output;
 end;
 format date date9.;
run;
data weight_tp(drop=i date_t: weight_t:);
 set weight;
 array datum(4)   date_t1 - date_t4;
 array ww(4)    weight_t1 - weight_t4;
 do i=1 to dim(datum);
  date=datum(i);
  weight=ww(i);
  output;
 end;
 format date date9.;
run;

data want;
 merge height_tp(in=hh) weight_tp(in=ww);
 by ID date;
 if NOT (hh and ww) then delete;
 height_div_weight_ratio=height/weight;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2024 17:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/919809#M362300</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2024-03-11T17:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Compute ratio from two database for a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/922826#M363359</link>
      <description>&lt;P&gt;Thanks a lot, it works !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Florian&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 19:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-ratio-from-two-database-for-a-given-date/m-p/922826#M363359</guid>
      <dc:creator>FlorianM</dc:creator>
      <dc:date>2024-04-03T19:22:32Z</dc:date>
    </item>
  </channel>
</rss>

