<?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 code explanation in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9539#M688</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be the OT's code is more about recoding (as ageg seems not to be retained)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Feb 2012 02:00:52 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2012-02-22T02:00:52Z</dc:date>
    <item>
      <title>code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9533#M682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I inherited a code and it i dont understand the meaning of the following piece ageg=1+1*(sex='F'); ,is it similar to a conditional check?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tt;&lt;/P&gt;&lt;P&gt; set t;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; ageg=1+1*(sex='F');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 01:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9533#M682</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2012-02-22T01:22:29Z</dc:date>
    </item>
    <item>
      <title>code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9534#M683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; The expression sex='F' will return 1 if true and 0 if false. If sex='F' then ageg will get the value assigned: 1+1*(1), else it will be: 1+1*(0). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe the following expression would do the same;&lt;/P&gt;&lt;P&gt;ageg= 1 +(sex='F');&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 01:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9534#M683</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-02-22T01:54:03Z</dc:date>
    </item>
    <item>
      <title>code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9535#M684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Hi,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; You are right. The statement &lt;SPAN style="background-color: #eef4f9;"&gt;sex='F' is used as logical expression which compares the value of variable sex with 'F' .&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.&amp;nbsp; If it matches it returns 1 so the sum result would be 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #eef4f9;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.&amp;nbsp; If it doesn't matches then the logical expression returns 0 so final result would be 0. &lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 01:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9535#M684</guid>
      <dc:creator>dav_amol</dc:creator>
      <dc:date>2012-02-22T01:55:33Z</dc:date>
    </item>
    <item>
      <title>code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9536#M685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is an excessive way of coding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ageg+&lt;SPAN style="background-color: #eef4f9;"&gt;(sex='F')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #eef4f9;"&gt;simply a count of the number of records that have a code of 'F' for the sex variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #eef4f9;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 01:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9536#M685</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-22T01:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9537#M686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, the more I look at it, it is simply wrong unless one wants to assign the value 2 to the ageg varoab;e fpr every record that has a value of 'F' for sex.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 01:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9537#M686</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-22T01:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9538#M687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; With just a slight modification to your existing code, you can see what happens with the evaluation of (sex='F').&lt;/P&gt;&lt;P&gt;I changed your program to use a few records from SASHELP.CLASS and the LOG output below shows you how X is set to 0 or 1 based on the value of SEX. Therefore, AGEG is set to either 2 or 1 based on the value of the SEX variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;3200&amp;nbsp; data tt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;3201&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;3202&amp;nbsp;&amp;nbsp;&amp;nbsp; where age le 13;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;3203&amp;nbsp;&amp;nbsp;&amp;nbsp; x = (sex='F');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;3204&amp;nbsp;&amp;nbsp;&amp;nbsp; ageg=1+1*(sex='F');;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;3205&amp;nbsp;&amp;nbsp;&amp;nbsp; put _n_= name= sex= x= ageg=;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;3206&amp;nbsp; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=1 Name=Alice Sex=F x=1 ageg=2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=2 Name=Barbara Sex=F x=1 ageg=2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=3 Name=James Sex=M x=0 ageg=1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=4 Name=Jane Sex=F x=1 ageg=2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=5 Name=Jeffrey Sex=M x=0 ageg=1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=6 Name=John Sex=M x=0 ageg=1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=7 Name=Joyce Sex=F x=1 ageg=2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=8 Name=Louise Sex=F x=1 ageg=2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=9 Name=Robert Sex=M x=0 ageg=1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;_N_=10 Name=Thomas Sex=M x=0 ageg=1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;NOTE: There were 10 observations read from the data set SASHELP.CLASS.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE age&amp;lt;=13;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: terminal,monaco;"&gt;NOTE: The data set WORK.TT has 10 observations and 7 variables.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 02:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9538#M687</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2012-02-22T02:00:40Z</dc:date>
    </item>
    <item>
      <title>code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9539#M688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be the OT's code is more about recoding (as ageg seems not to be retained)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 02:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9539#M688</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-02-22T02:00:52Z</dc:date>
    </item>
    <item>
      <title>code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9540#M689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cynthia is correct, of course, but if that was the intent, it will also score a 1 for any missing value of sex.&amp;nbsp; e.g., try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if age eq 13 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(sex);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ageg=1+1*(sex='F');;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 02:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9540#M689</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-22T02:28:15Z</dc:date>
    </item>
    <item>
      <title>code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9541#M690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your valuable suggestions!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 16:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/code-explanation/m-p/9541#M690</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2012-02-22T16:29:55Z</dc:date>
    </item>
  </channel>
</rss>

