<?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: Yes /No format in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645098#M30948</link>
    <description>&lt;P&gt;I am creating the step but I want a yes/no value for my output data for depression&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 May 2020 21:03:43 GMT</pubDate>
    <dc:creator>ED18</dc:creator>
    <dc:date>2020-05-04T21:03:43Z</dc:date>
    <item>
      <title>Yes /No format</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645095#M30946</link>
      <description>&lt;DIV class="post-info"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;I'm trying to figure out how to use yes/no statement in my if/then statement. How do I apply this update to the dataset variable using a character yes/no format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data final;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set data_thesis;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where 20&amp;lt;=RIDAGEYR&amp;lt;=35 &amp;amp; RIDRETH3=4 &amp;amp; RIAGENDR=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array _dpq dpq:;&lt;/P&gt;&lt;P&gt;do over _dpq;&lt;/P&gt;&lt;P&gt;if (_dpq &amp;gt;= 7) then call missing(_dpq);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;Depression_Score = sum(of dpq010-dpq090);&lt;/P&gt;&lt;P&gt;if 0 &amp;lt;= Depression_Score &amp;lt; 10 then Depression_Indicator = 'No';&lt;/P&gt;&lt;P&gt;else if Depression_Score &amp;gt;= 10 then Depression_Indicator = 'Yes';&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if sddsrvyr in (8,9) then MEC4YR = 1/2 * WTMEC2YR;&lt;BR /&gt;&lt;BR /&gt;if riagendr = 1 then Gender = 'Male ';&lt;/P&gt;&lt;P&gt;else if riagendr =2 then Gender = 'Female';&lt;/P&gt;&lt;P&gt;if LBXTC &amp;gt; 180 then Cholesterol = 'Prevalent ';&lt;BR /&gt;else if 0&amp;lt;=LBXTC&amp;lt;=180 then Cholesterol = 'Not Prevalent';&lt;/P&gt;&lt;P&gt;if LBDHDD &amp;gt; 60 then HDL = 'Prevalent';&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;else if 0&amp;lt;=LBDHDD&amp;lt;=60 then HDL = 'Not Prevalent';;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if LBXTR &amp;gt; 150 then Triglycerides = 'Prevalent ';&lt;/P&gt;&lt;P&gt;else if 0&amp;lt;=LBXTR&amp;lt;=150 THEN Triglycerides = 'Not Prevalent';&lt;/P&gt;&lt;P&gt;if LBDLDL &amp;gt; 100 then LDL = 'Prevalent';&lt;/P&gt;&lt;P&gt;else if 0&amp;lt;=LBDLDL&amp;lt;=100 then LDL = 'Not Prevalent';&lt;/P&gt;&lt;P&gt;keep SEQN Depression_Score Depression_Indicator Cholesterol YesNo MEC4YR HDL LDL Triglycerides Gender RIDAGEYR RIDRETH3 RIAGENDR SDMVPSU WTMEC2YR SDMVSTRA LBXTC LBDLDL LBXTR LBDHDD;&lt;BR /&gt;run;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 04 May 2020 20:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645095#M30946</guid>
      <dc:creator>ED18</dc:creator>
      <dc:date>2020-05-04T20:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Yes /No format</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645097#M30947</link>
      <description>&lt;P&gt;In SAS the word FORMAT has a specific meaning. A format is instructions for how to display a value as text.&amp;nbsp; It doesn't sound like you are actually talking about any formats.&amp;nbsp; I don't see any formats being defined or used in your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you are just asking something about how to use a character variable that has value like 'Yes' or 'No' ?&lt;/P&gt;
&lt;P&gt;Which variable is that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it one that existed in the input dataset?&amp;nbsp; Or are you trying to create it in this step?&amp;nbsp; If you are creating it make sure to define it as being at least three bytes long so that there is room to store both No and Yes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is it that you want to do with this variable that is causing your trouble?&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 21:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645097#M30947</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-04T21:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Yes /No format</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645098#M30948</link>
      <description>&lt;P&gt;I am creating the step but I want a yes/no value for my output data for depression&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 21:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645098#M30948</guid>
      <dc:creator>ED18</dc:creator>
      <dc:date>2020-05-04T21:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Yes /No format</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645105#M30950</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327070"&gt;@ED18&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am creating the step but I want a yes/no value for my output data for depression&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My mind reading powers are off today.&amp;nbsp; What exactly is your question?&lt;/P&gt;
&lt;P&gt;Are you asking how to create a custom format that will display values of&amp;nbsp;&lt;SPAN&gt;Depression_Score&amp;nbsp;as No or Yes?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
 values depyesno
  0 - &amp;lt;10 = 'No'
10 - high = 'Yes'
 ;
run;

proc freq data=final;
  tables depression_score;
  format depression_score depyesno.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 May 2020 21:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645105#M30950</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-04T21:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Yes /No format</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645107#M30951</link>
      <description>&lt;P&gt;I generally suggest that instead of character values like yes/no true/false, has condtion x/ does not to use numeric values of 1/0.&lt;/P&gt;
&lt;P&gt;So instead of&lt;/P&gt;
&lt;PRE&gt;if 0 &amp;lt;= Depression_Score &amp;lt; 10 then Depression_Indicator = 'No';
else if Depression_Score &amp;gt;= 10 then Depression_Indicator = 'Yes';&lt;/PRE&gt;
&lt;P&gt;Something like&lt;/P&gt;
&lt;PRE&gt;if not missing(Depression_Score) then Depression_Indicator =(Depression_Score &amp;gt;= 10);&lt;/PRE&gt;
&lt;P&gt;SAS will create 1/0 values for true/false comparisons.&lt;/P&gt;
&lt;P&gt;One reason to use 1/0 coded values is you can request the SUM of the variable to get the number of 1(or Yes) values and the Mean is the percent yes.&lt;/P&gt;
&lt;P&gt;A custom format can display the text Yes/No when needed:&lt;/P&gt;
&lt;PRE&gt;Proc format;
value yn
1='Yes'
0='No'
other=' ';
run;&lt;/PRE&gt;
&lt;P&gt;A similar format could display the words "Prevalent" or "not prevalent" by setting the 1/0 condition.&lt;/P&gt;
&lt;P&gt;OR since your values appear to be numeric to begin based on single variables you could likely skip creating the new variables entirely.&lt;/P&gt;
&lt;PRE&gt;proc format;
value depression
0 -&amp;lt;10 = "No"
10-high = "Yes"
;
value gender
1='Male'
2='Female'
;
value lbxtc
0 - 180 ='Not Prevalent'
180&amp;lt;high = 'Prevalent'
;
/* follow the pattern for LBDHDD etc*/
run;

proc print data=data_thesis;
   var Depression_Score riagendr  LBXTC ;
   format Depression_Score depression.   riagendr gender.
      LBXTC LBXTC.;
   ;
run;&lt;/PRE&gt;
&lt;P&gt;The groups created by formats are generally usable by analysis, graphing and report procedures.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The difference might come in if you need/want to do something with how many conditions have a 'Yes' or 'prevalent' condition. Then if you use the 1/0 coding then summing them gives you a per person count.&lt;/P&gt;
&lt;P&gt;Without duplicating a lot of if/then/else code in counting.&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 21:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Yes-No-format/m-p/645107#M30951</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-04T21:37:29Z</dc:date>
    </item>
  </channel>
</rss>

