<?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: Calculate BMI Dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555787#M154717</link>
    <description>&lt;P&gt;Some questions you should answer before going any further:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have any units other than kg and M for weight and height? If so you will need to get everything into the same units.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next is you need to get the height and weight measure on the same record to have both variables available to do the calculation.&lt;/P&gt;
&lt;P&gt;That is often a transpose something similar to:&lt;/P&gt;
&lt;PRE&gt;proc sort data=have;
   by patient visitdate;
run;

proc transpose data=have out=need;
by patient visitdate;
id type unit;
var value;
run;&lt;/PRE&gt;
&lt;P&gt;You would use the NEED data set just built in another data step to do the actual bmi calculation. If you have more than one set of measurement units for height and weight though you will want to get Height in m and weigth in KG from them.&lt;/P&gt;
&lt;P&gt;Then&lt;/P&gt;
&lt;P&gt;bmi = weightkg / heightm**2;&lt;/P&gt;
&lt;P&gt;the **2 is one way to do exponentiation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know if your date values got scrambled on pasting here but that particular format is going to be a pain to deal with.&lt;/P&gt;
&lt;P&gt;You will usually want to get your dates into a SAS date value&amp;nbsp; so you can use the functions and formats to manipulate the dates but the values you show are going to be a bit obnoxious to read into SAS dates.&lt;/P&gt;</description>
    <pubDate>Fri, 03 May 2019 22:55:57 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-05-03T22:55:57Z</dc:date>
    <item>
      <title>Calculate BMI Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555783#M154713</link>
      <description>&lt;P&gt;I have a dataset that looks like the following for many patients&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Patient&amp;nbsp; &amp;nbsp; &amp;nbsp; VisitDate&amp;nbsp; &amp;nbsp; &amp;nbsp;Value&amp;nbsp; &amp;nbsp; &amp;nbsp;Unit&amp;nbsp; &amp;nbsp; &amp;nbsp;Type&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan12019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;m&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Height&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan12019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kg&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Weight&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan52019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;m&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Height&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan52019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;55&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kg&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Weight&lt;/P&gt;&lt;P&gt;I am trying to add BMI to get the following dataset for those patients:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Patient&amp;nbsp; &amp;nbsp; &amp;nbsp;VisitDate&amp;nbsp; &amp;nbsp; &amp;nbsp; Value&amp;nbsp; &amp;nbsp; &amp;nbsp;Unit&amp;nbsp; &amp;nbsp; &amp;nbsp; Type&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan12019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Height&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jan12019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kg&amp;nbsp; &amp;nbsp; &amp;nbsp; Weight&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan52019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Height&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jan52019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;55&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kg&amp;nbsp; &amp;nbsp; &amp;nbsp; Weight&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jan12019&amp;nbsp; &amp;nbsp; &amp;nbsp;50/1^2&amp;nbsp; &amp;nbsp; kg/m2&amp;nbsp; &amp;nbsp; &amp;nbsp;BMI&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jan52019&amp;nbsp; &amp;nbsp; &amp;nbsp;55/2^2&amp;nbsp; &amp;nbsp; kg/m2&amp;nbsp; &amp;nbsp; &amp;nbsp;BMI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand the logic beyond programming this in SAS. Below is what I have so far in psuedo code:&lt;/P&gt;&lt;P&gt;Create BMI data set. For each patient on each visit date, value = weight/height^2. Type = BMI. Unit = kg/m2. Keep Patient, VisitDate info.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 22:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555783#M154713</guid>
      <dc:creator>serena13lee</dc:creator>
      <dc:date>2019-05-02T22:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate BMI Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555787#M154717</link>
      <description>&lt;P&gt;Some questions you should answer before going any further:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have any units other than kg and M for weight and height? If so you will need to get everything into the same units.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next is you need to get the height and weight measure on the same record to have both variables available to do the calculation.&lt;/P&gt;
&lt;P&gt;That is often a transpose something similar to:&lt;/P&gt;
&lt;PRE&gt;proc sort data=have;
   by patient visitdate;
run;

proc transpose data=have out=need;
by patient visitdate;
id type unit;
var value;
run;&lt;/PRE&gt;
&lt;P&gt;You would use the NEED data set just built in another data step to do the actual bmi calculation. If you have more than one set of measurement units for height and weight though you will want to get Height in m and weigth in KG from them.&lt;/P&gt;
&lt;P&gt;Then&lt;/P&gt;
&lt;P&gt;bmi = weightkg / heightm**2;&lt;/P&gt;
&lt;P&gt;the **2 is one way to do exponentiation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know if your date values got scrambled on pasting here but that particular format is going to be a pain to deal with.&lt;/P&gt;
&lt;P&gt;You will usually want to get your dates into a SAS date value&amp;nbsp; so you can use the functions and formats to manipulate the dates but the values you show are going to be a bit obnoxious to read into SAS dates.&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2019 22:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555787#M154717</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-03T22:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate BMI Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555788#M154718</link>
      <description>Hi and thanks for your response. To answer your concerns, I do not have any other units other than kg and m. I am using dummy dates since I am more concerned about logic. I can change that to a SAS date.</description>
      <pubDate>Thu, 02 May 2019 22:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555788#M154718</guid>
      <dc:creator>serena13lee</dc:creator>
      <dc:date>2019-05-02T22:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate BMI Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555790#M154720</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Patient $     VisitDate $   Value     Unit  $   Type $;
cards;
A Jan12019 1 m Height
A Jan12019 50 kg Weight
A Jan52019 2 m Height
A Jan52019 55 kg Weight
;

proc sort data=have;
by patient VisitDate;
run;

data want;
set have;
by patient VisitDate;
retain height_;
if first.VisitDate then height_=.;
if type='Height' then height_=Value;
if last.VisitDate then bmi=value/height_**2;
output;
if bmi ne . then do;
type='BMI';
value=bmi;
unit='kg/m2';
output;
end;
drop height_ bmi;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 May 2019 22:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-BMI-Dataset/m-p/555790#M154720</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-02T22:14:14Z</dc:date>
    </item>
  </channel>
</rss>

