<?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: &amp;quot;if and THEN&amp;quot; conditional programming. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437534#M69026</link>
    <description>Der superuser, nice to hear from you.&lt;BR /&gt;&lt;BR /&gt;Apologies for not attaching sample data. Plese, find attached.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please find attached my sample data set.&lt;BR /&gt;</description>
    <pubDate>Thu, 15 Feb 2018 12:26:55 GMT</pubDate>
    <dc:creator>Achieng</dc:creator>
    <dc:date>2018-02-15T12:26:55Z</dc:date>
    <item>
      <title>"if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437430#M69021</link>
      <description>&lt;P&gt;"if and THEN" conditional programming.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Dear Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this email finds you well. Thank you for all your help. I have learned a lot from the other responses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a little help with some programming,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am analyzing data and would like to meet some conditions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a group of metabolic syndrome participants and non-metabolic one. I would like to classify them into metabolically healthy normal weight (MHNW), metabolically Unhealthy normal weight (MUNW) and metabolically healthy overweight (MHO) and metabolically unhealthy overweight (MUO).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data Alisama;set Alisama;
log_waist=log(Waistcm);/**add log forthe other variables/
/*do it with non normally distributed outcomes*/
log_CRP=log(CRP_High_S);
label T2DMMetS_ALL ="T2DM";
met_s=0;
if MetS_Total&amp;gt;=3 then met_s=1;
array score score0-score5;
do i=0 to 5;
score[i]=0;
end;
     if Gender_Code_2005=1 &amp;amp; Waist_2015&amp;gt;=94                                       then score1=1;*codes for men;
else if Gender_Code_2005=2 &amp;amp; Waist_2015&amp;gt;=80                                       then score1=1;*codes for women;

if TRIG2015&amp;gt;=1.7                                                            then score2=1;

     if Gender_Code_2005=1 &amp;amp; HDLC32015&amp;lt;=1                                        then score3=1;*codes for men;
else if Gender_Code_2005=2 &amp;amp; HDLC32015&amp;lt;=1.3                                      then score3=1;*codes for women;

     if SBPOmr2015&amp;gt;=130 or DBP2015&amp;gt;=85 or HT_MED2015=1     then score4=1;*codes for men;
	 if Glucose2015&amp;gt;=5.6                          or DIAB_MED2015=1 then score5=1;*codes for men;
MetS_Total=sum(of score0-score5);
met_s2=0;if MetS_Total&amp;gt;=3 then met_s2=1;

run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;met_s2 Frequency Percent CumulativeFrequency CumulativePercent01 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;188&lt;/TD&gt;&lt;TD&gt;69.63&lt;/TD&gt;&lt;TD&gt;188&lt;/TD&gt;&lt;TD&gt;69.63&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;82&lt;/TD&gt;&lt;TD&gt;30.37&lt;/TD&gt;&lt;TD&gt;270&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;score_MS Frequency Percent CumulativeFrequency CumulativePercent012345 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;8.89&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;8.89&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;85&lt;/TD&gt;&lt;TD&gt;31.48&lt;/TD&gt;&lt;TD&gt;109&lt;/TD&gt;&lt;TD&gt;40.37&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;79&lt;/TD&gt;&lt;TD&gt;29.26&lt;/TD&gt;&lt;TD&gt;188&lt;/TD&gt;&lt;TD&gt;69.63&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;19.26&lt;/TD&gt;&lt;TD&gt;240&lt;/TD&gt;&lt;TD&gt;88.89&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;10.00&lt;/TD&gt;&lt;TD&gt;267&lt;/TD&gt;&lt;TD&gt;98.89&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1.11&lt;/TD&gt;&lt;TD&gt;270&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;I have already classified the metabolical syndrome and the above are the numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, whatever I do, I have failed to get the qualifications mentioned above right,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is here&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data ALLMH05TO15; set ALLMH05TO15;
  if BMI_2015 &amp;lt;=24.99999 &amp;amp; met_s2=0                    then MHNW=0;
if BMI_2015 &amp;gt;=25.0 &amp;amp; met_s2=0                        	then MHO=1;
run;

if BMI_2015 &amp;lt;=24.99999 &amp;amp; met_s2=1     				then MUNW=0;
 if BMI_2015 &amp;gt;=25.0 &amp;amp; met_s2=1  						then MUO=1;

run;&lt;/PRE&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV class="c proctitle"&gt;The FREQ Procedure&lt;/DIV&gt;&lt;DIV class="c proctitle"&gt;These are the results I am generating thing which is not adding up.&lt;/DIV&gt;&lt;DIV class="c proctitle"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;SAS Output&lt;DIV class="branch"&gt;&lt;DIV class="c proctitle"&gt;The FREQ Procedure&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MHNWMHNW Frequency Percent CumulativeFrequency CumulativePercent01 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;171&lt;/TD&gt;&lt;TD&gt;63.33&lt;/TD&gt;&lt;TD&gt;171&lt;/TD&gt;&lt;TD&gt;63.33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;99&lt;/TD&gt;&lt;TD&gt;36.67&lt;/TD&gt;&lt;TD&gt;270&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MHO Frequency Percent CumulativeFrequency CumulativePercent1Frequency Missing = 218 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MUNW Frequency Percent CumulativeFrequency CumulativePercent01Frequency Missing = 188 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;24.39&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;24.39&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;62&lt;/TD&gt;&lt;TD&gt;75.61&lt;/TD&gt;&lt;TD&gt;82&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MUO Frequency Percent CumulativeFrequency CumulativePercent1Frequency Missing = 208 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;62&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;TD&gt;62&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So I tried another method..&lt;/P&gt;&lt;PRE&gt;data ALLMH05TO15;set ALLMH05TO15;


 if BMI_2015&amp;lt;=24.99999 &amp;amp; MetS_Total_2015=0                        then MHNW=0;
 if BMI_2015&amp;lt;=24.99999 &amp;amp; MetS_Total_2015=1     						then MHNW=0;
 if BMI_2015&amp;lt;=24.99999 &amp;amp; MetS_Total_2015=2     						then MHNW=0;
 if BMI_2015&amp;lt;=24.99999 &amp;amp; MetS_Total_2015&amp;gt;=3     						then MUNW=1;


if BMI_2015 &amp;gt;=25.0 &amp;amp; MetS_Total_2015=0                        	then MHNW=1;
if BMI_2015 &amp;gt;=25.0 &amp;amp; MetS_Total_2015=1  							then MHNW=1;
if BMI_2015 &amp;gt;=25.0 &amp;amp; MetS_Total_2015=2  							then MHNW=1;

if BMI_2015 &amp;lt;=24.99999 &amp;amp; MetS_Total_2015&amp;gt;=3                           then MUNW=0;
if  BMI_2015 &amp;gt;=25.0 &amp;amp; MetS_Total_2015&amp;gt;=3                             then MUNW=1;

run;&lt;/PRE&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;These are the results&amp;nbsp;&lt;/DIV&gt;&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV align="center"&gt;SAS Output&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MHNWMHNW Frequency Percent CumulativeFrequency CumulativePercent01 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;171&lt;/TD&gt;&lt;TD&gt;63.33&lt;/TD&gt;&lt;TD&gt;171&lt;/TD&gt;&lt;TD&gt;63.33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;99&lt;/TD&gt;&lt;TD&gt;36.67&lt;/TD&gt;&lt;TD&gt;270&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MUNW Frequency Percent CumulativeFrequency CumulativePercent01Frequency Missing = 188 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;24.39&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;24.39&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;62&lt;/TD&gt;&lt;TD&gt;75.61&lt;/TD&gt;&lt;TD&gt;82&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;So I don't know what I am doing wrong,&lt;/DIV&gt;&lt;DIV&gt;I would like to get a column with the exact numbers.&amp;nbsp;I understand the last&amp;nbsp;results, but not the first. Please help.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Worried Ph.D. student&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;New SAS user,&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 15 Feb 2018 07:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437430#M69021</guid>
      <dc:creator>Achieng</dc:creator>
      <dc:date>2018-02-15T07:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437457#M69022</link>
      <description>&lt;P&gt;I cannot tell from what you post, as always, first step is to provide test data in the form of a datastep.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect your if statement is not capturing all eventualities for instance:&lt;/P&gt;
&lt;PRE&gt;if BMI_2015&amp;lt;=24.99999 &amp;amp; MetS_Total_2015&amp;gt;=3     						then MUNW=1;


if BMI_2015 &amp;gt;=25.0 &amp;amp; MetS_Total_2015=0      &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;What if bmi_2015 = 24.999991?&amp;nbsp; Neither of those if statements would trigger.&amp;nbsp; One way to capture all would be:&lt;/P&gt;
&lt;PRE&gt;if bmi_2015 &amp;lt;= 24.99999 then do;
  ...
end;
else do;
  ...
end;&lt;/PRE&gt;
&lt;P&gt;And nestle your statements.&amp;nbsp; Also, your numbers may contain a very small fraction of a number (due to storage on the machine), so rounding the value may also help.&amp;nbsp; Also, avoid coding in mixed code and use indents so its easy to read the code.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 09:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437457#M69022</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-15T09:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437534#M69026</link>
      <description>Der superuser, nice to hear from you.&lt;BR /&gt;&lt;BR /&gt;Apologies for not attaching sample data. Plese, find attached.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please find attached my sample data set.&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Feb 2018 12:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437534#M69026</guid>
      <dc:creator>Achieng</dc:creator>
      <dc:date>2018-02-15T12:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437542#M69027</link>
      <description>&lt;P&gt;Dear Superuser, sample data attached. Apologies for not attaching earlier. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 12:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437542#M69027</guid>
      <dc:creator>Achieng</dc:creator>
      <dc:date>2018-02-15T12:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437552#M69028</link>
      <description>&lt;P&gt;You may need to run this step first. Thank you very much for your help&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Sample_Ac;set Sample_Ac;
met_s=0;
if MetS_Total&amp;gt;=3 then met_s=1;
array score score1-score5;
do i=1 to 5;
score[i]=0;
end;

if Gender_Code_2005=1 &amp;amp; Waist_2015&amp;gt;=94                then score1=1;*codes for men;
else if Gender_Code_2005=2 &amp;amp; Waist_2015&amp;gt;=80           then score1=1;*codes for women;

if TRIG2015&amp;gt;=1.7       								  then score2=1;

if Gender_Code_2005=1 &amp;amp; HDLC32015&amp;lt;=1                  then score3=1;*codes for men;
else if Gender_Code_2005=2 &amp;amp; HDLC32015&amp;lt;=1.3           then score3=1;*codes for women;

if SBPOmr2015&amp;gt;=130 or DBP2015&amp;gt;=85 or HT_MED2015=1     then score4=1;
if Glucose2015&amp;gt;=5.6      or T2DM2015=1 				  then score5=1;

score_MS=sum(of score1-score5);
met_s2=0;if score_MS&amp;gt;=3 then met_s2=1;
run;


Proc freq data = Sample_Data;   tables met_s2  score_MS;
run; 


data Sample_Ac; set Sample_Ac;
rename score_MS= MetS_Total_2015;*rename old=new*;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Feb 2018 12:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437552#M69028</guid>
      <dc:creator>Achieng</dc:creator>
      <dc:date>2018-02-15T12:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437586#M69029</link>
      <description>&lt;P&gt;Sorry, you misunderstand, I don't want to open Excel files, nor do I want to write import programs to try to deal with those or guess your data.&amp;nbsp; I want you to provide, in a datastep, some test data which shows what you have, what the structure of the dataset is, and what you want out at the end.&amp;nbsp; Follow this post if need:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 14:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437586#M69029</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-15T14:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437697#M69041</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With appropriate formats for continuous variables this will create a grid that shows which combinations of values were assigned which score and may help find missing or overcounts&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data= Alisama;
   class Gender_Code_2005   Waist_2015  TRIG2015 HDLC32015
   SBPOmr2015 DBP2015 HT_MED2015 Glucose2015   DIAB_MED2015 /missing;
   /* your continuous variables should have a format to indicate the &amp;gt;, &amp;lt; or
      the range of interest and have a corresponding
      format assignment statment here
   */
   var score0 - score5;
   table  Gender_Code_2005 * Waist_2015 * TRIG2015 HDLC32015*
      SBPOmr2015* DBP2015* HT_MED2015 Glucose2015   *DIAB_MED2015 ,
      (score0 score1 score2 score3 score4 score5)*sum=''
      / misstext=' '
   ;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I would be very cautious of habitual use of&lt;/P&gt;
&lt;PRE&gt;data Alisama;set Alisama;&lt;/PRE&gt;
&lt;P&gt;as that has a potential for creating all sorts of chaos as testing this sort of recode if any of the independent variables (waist for instance) has adjustment code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 17:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/437697#M69041</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-15T17:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/438352#M69088</link>
      <description>Hello Superuser,&lt;BR /&gt;I have been unable to create the data set you wanted,&lt;BR /&gt;I am using SAS 9.4. I don't know what I am doing wrong,&lt;BR /&gt;have 270 observations and 298 variables.&lt;BR /&gt;Please help.&lt;BR /&gt;&lt;BR /&gt;I have not resolved the original problem I posted last week.&lt;BR /&gt;Thank you.&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Feb 2018 08:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/438352#M69088</guid>
      <dc:creator>Achieng</dc:creator>
      <dc:date>2018-02-19T08:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/438353#M69089</link>
      <description>&lt;P&gt;There is nothing I can do, I cannot see your data to tell you where you are going wrong.&amp;nbsp; All I can repeat is that this:&lt;/P&gt;
&lt;PRE&gt; if BMI_2015&amp;lt;=24.99999 &amp;amp; MetS_Total_2015&amp;gt;=3 then MUNW=1;
if BMI_2015 &amp;gt;=25.0 &amp;amp; MetS_Total_2015=0 then MHNW=1;
&lt;/PRE&gt;
&lt;P&gt;Does not cover all evenetualities - 24.999991 for instance would get flagged.&amp;nbsp; I have suggested other methods to cover all eventualities, have you tried these?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if bmi_2015 &amp;lt;= 24.99999 ... do;
  ...
end;
else do;
   ...
end;&lt;/PRE&gt;
&lt;P&gt;Without information on what you are using I cannot do anything.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2018 09:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/438353#M69089</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-19T09:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/438418#M69093</link>
      <description>&lt;P&gt;Hello Superuser,&lt;/P&gt;&lt;P&gt;I don't know what I am doing wrong, I about to die, I have been unable to solve this problem since last week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried what you advised. So I went ahead and categorized the two BMI categories.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ALLMH05TO15; set ALLMH05TO15;

 if BMI_2015 &amp;lt;= 24.794988736 	then BMICAT=0;
if  BMI_2015 =&amp;gt; 25.004109139	 	then BMICAT=1;


run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I then went ahead to classify my metabolic syndrome.&lt;/P&gt;&lt;P&gt;Metabolic healthy&amp;nbsp;with Normal weight (MHNW)&lt;/P&gt;&lt;P&gt;Metabolically healthy overweight/obese (MHO)&lt;/P&gt;&lt;P&gt;Metabolically Unhelathy Normla weight (MUNW)&lt;/P&gt;&lt;P&gt;Metabolically unhealthy&amp;nbsp;overweight/obese (MUO)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in other words, I need to combine the MetS_total_2015 and he BMI category which I&amp;nbsp;have included up there to meet the conditions for the MHNW, MUNW, MHO, MUO.&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MetS_Total_2015 Frequency Percent CumulativeFrequency CumulativePercent012345 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;8.89&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;8.89&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;85&lt;/TD&gt;&lt;TD&gt;31.48&lt;/TD&gt;&lt;TD&gt;109&lt;/TD&gt;&lt;TD&gt;40.37&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;79&lt;/TD&gt;&lt;TD&gt;29.26&lt;/TD&gt;&lt;TD&gt;188&lt;/TD&gt;&lt;TD&gt;69.63&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;19.26&lt;/TD&gt;&lt;TD&gt;240&lt;/TD&gt;&lt;TD&gt;88.89&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;10.00&lt;/TD&gt;&lt;TD&gt;267&lt;/TD&gt;&lt;TD&gt;98.89&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1.11&lt;/TD&gt;&lt;TD&gt;270&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attempted to classify&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data ALLMH05TO15; set ALLMH05TO15;

if MetS_Total_2015 &amp;lt;= 2	&amp;amp; BMICAT=0 		then MHNW=0;
if MetS_Total_2015 =&amp;gt;3 	&amp;amp; BMICAT=0  	then MUNW=0;


if MetS_Total_2015 &amp;lt;= 2 &amp;amp; BMICAT=1		then MHNW=1;
if MetS_Total_2015 =&amp;gt;3 	&amp;amp; BMICAT=1  	then MUNW=1;

run;&lt;/PRE&gt;&lt;P&gt;These are the results I&amp;nbsp;am getting&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MHNWMHNW Frequency Percent CumulativeFrequency CumulativePercent01 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;155&lt;/TD&gt;&lt;TD&gt;57.41&lt;/TD&gt;&lt;TD&gt;155&lt;/TD&gt;&lt;TD&gt;57.41&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;115&lt;/TD&gt;&lt;TD&gt;42.59&lt;/TD&gt;&lt;TD&gt;270&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;MUNW Frequency Percent CumulativeFrequency CumulativePercent01Frequency Missing = 188 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;24.39&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;24.39&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;62&lt;/TD&gt;&lt;TD&gt;75.61&lt;/TD&gt;&lt;TD&gt;82&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second set of results are correct (MUNW). however, the first set (MHNW) is wrong, it is including all the data to give me a total of&amp;nbsp;270, yet I should have a total of 188 and not 270. Please, I hope someone can understand my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a feeling the problem lies in the metabolic syndrome category... but I keep getting an error,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1024  data ALLMH05TO15; set ALLMH05TO15;
1025  met_s=0;
1026  if MetS_Total&amp;gt;=3 then met_s=1;
1027  array score score0-score5;
1028  do i=0 to 5;
1029  score[i]=0;
1030  end;
1031       if Gender_Code_2005=1 &amp;amp; Waist_2015&amp;gt;=94                                       then
1031! score1=1;*codes for men;
1032  else if Gender_Code_2005=2 &amp;amp; Waist_2015&amp;gt;=80                                       then
1032! score1=1;*codes for women;
1033
1034  if TRIG2015&amp;gt;=1.7                                                            then score2=1;
1035
1036       if Gender_Code_2005=1 &amp;amp; HDLC32015&amp;lt;=1                                        then score3=1
1036! ;*codes for men;
1037  else if Gender_Code_2005=2 &amp;amp; HDLC32015&amp;lt;=1.3                                      then score3=1
1037! ;*codes for women;
1038
1039       if SBPOmr2015&amp;gt;=130 or DBP2015&amp;gt;=85 or HT_MED2015=1     then score4=1;*codes for men;
1040       if Glucose2015&amp;gt;=5.6                          or DIAB_MED2015=1 then score5=1;*codes for
1040! men;
1041  MetS_Total=sum(of score0-score5);
1042  met_s2=0;if MetS_Total&amp;gt;=3 then met_s2=1;
1043
1044  run;

ERROR: Array subscript out of range at line 1029 column 1.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no help, I am&amp;nbsp;depending on all of you;).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&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;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Achieng&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2018 15:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/438418#M69093</guid>
      <dc:creator>Achieng</dc:creator>
      <dc:date>2018-02-19T15:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: "if and THEN" conditional programming.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/439652#M69145</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I managed to resolve the issues. I had to go manually to the data set to find out what was wrong,&lt;/P&gt;&lt;P&gt;I found that some of the variables had Metabolic syndrome classification but were missing BMI values, and others had the&amp;nbsp;BMI status but were missing the metabolic system classification. Once I deleted these, I was able to&amp;nbsp;resolve the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;very kind regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 11:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-if-and-THEN-quot-conditional-programming/m-p/439652#M69145</guid>
      <dc:creator>Achieng</dc:creator>
      <dc:date>2018-02-23T11:01:19Z</dc:date>
    </item>
  </channel>
</rss>

