<?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: Piecewise linear regression in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Piecewise-linear-regression/m-p/907151#M358127</link>
    <description>Check &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; 's blogs:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/04/05/nonsmooth-models-spline-effects.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/04/05/nonsmooth-models-spline-effects.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2020/12/14/segmented-regression-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2020/12/14/segmented-regression-sas.html&lt;/A&gt;</description>
    <pubDate>Sat, 09 Dec 2023 09:39:04 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-12-09T09:39:04Z</dc:date>
    <item>
      <title>Piecewise linear regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Piecewise-linear-regression/m-p/907150#M358126</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am completing an assignment that involves constructing new variables in my code I am supposed to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. create a formula for BMI&lt;/P&gt;&lt;P&gt;2. compute a Categorical BMI variable in which 1=normal (&amp;lt;25) , 2=overweight (25 to &amp;lt;30) and 3=obese&lt;/P&gt;&lt;P&gt;3. three piecewise variables for the BMI intervals as defined in the Categorical BMI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, does my code satisfy the piecewise variables? In our lecture, there are a lot of long and drawn out ways to create piecewise variables but I want to ensure this is being done correctly for analysis. Here is my code:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;proc format;&lt;/DIV&gt;&lt;DIV&gt;value BMIcatf 1='normal' 2='overweight' 3= 'obese';&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data final;&lt;/DIV&gt;&lt;DIV&gt;set totalcohort;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;weight_kg = (weight / 2.205);&lt;/DIV&gt;&lt;DIV&gt;height_m = (height * 0.0254);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;BMI = (weight_kg) / (height_m **2); *should we have to square the value for correct BMI?*;&lt;/DIV&gt;&lt;DIV&gt;if BMI &amp;gt;=19;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;if BMI &amp;lt;25 then BMIcat = 1;&lt;/DIV&gt;&lt;DIV&gt;else if BMI &amp;nbsp;&amp;gt;= 25 and BMI &amp;lt; 30 then BMIcat = 2;&lt;/DIV&gt;&lt;DIV&gt;else &amp;nbsp;BMIcat = 3;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;BMI1 = BMI &amp;lt; 25;&lt;/DIV&gt;&lt;DIV&gt;BMI2 = BMI &amp;gt;= 25 and BMI &amp;lt;30;&lt;/DIV&gt;&lt;DIV&gt;BMI3 = BMI &amp;gt;=30;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;waist_hip_ratio = (waist / hip);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;meanSBP = (bp_1s + bp_2s) / 2;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;log_glyhb = log(glyhb);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;if gender = 'male' then male =1;&lt;/DIV&gt;&lt;DIV&gt;else male = 0;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;format BMIcat BMIcatf.;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Sat, 09 Dec 2023 06:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Piecewise-linear-regression/m-p/907150#M358126</guid>
      <dc:creator>PunkinSAS08</dc:creator>
      <dc:date>2023-12-09T06:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Piecewise linear regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Piecewise-linear-regression/m-p/907151#M358127</link>
      <description>Check &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; 's blogs:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/04/05/nonsmooth-models-spline-effects.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/04/05/nonsmooth-models-spline-effects.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2020/12/14/segmented-regression-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2020/12/14/segmented-regression-sas.html&lt;/A&gt;</description>
      <pubDate>Sat, 09 Dec 2023 09:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Piecewise-linear-regression/m-p/907151#M358127</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-12-09T09:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Piecewise linear regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Piecewise-linear-regression/m-p/907187#M358140</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;gt; &lt;EM&gt;3. three piecewise variables for the BMI intervals&lt;/EM&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You have constructed one categorical variable (BMIcat), which has the values 1,2,3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You have created three binary indicator variables (often called "dummy variables"), which you have named&amp;nbsp;BMI1,&amp;nbsp;BMI2, and&amp;nbsp;BMI3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't know how your instructor defines a "piecewise variable." If you use that term to mean a binary indicator variable, then this looks fine. If it means something else, we need to know the definition.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would delete the line&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if BMI &amp;gt;=19;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;unless you purposely want to exclude underweight people.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Dec 2023 10:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Piecewise-linear-regression/m-p/907187#M358140</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-12-10T10:39:20Z</dc:date>
    </item>
  </channel>
</rss>

