<?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: Basic data step question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107895#M258680</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"However, in looking at your code, shouldn't your current if statements really be a set of if, then, else statements as well?" I don't understand this. Could you be more explicit?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Oct 2012 15:22:20 GMT</pubDate>
    <dc:creator>aklr86</dc:creator>
    <dc:date>2012-10-26T15:22:20Z</dc:date>
    <item>
      <title>Basic data step question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107893#M258678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems like a really basic question. When creating a variable within a data step, is it possible to refer to that variable within the same data step? When I try to run the following code, I get the error "&lt;SPAN style="color: #ff0000;"&gt;ERROR: Variable fthursDiag is not on file MAVEN.dd_aow_events&lt;/SPAN&gt;". There are ways around this of course, but it is something I've run into a few times and have yet to find a solution for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data aow1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set maven.dd_aow_events;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;*-- convert dates;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;array date birth_date disease_status_date investigation_status_date diagnosis_date onset_date &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; event_create_date event_modification_date; &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;do over date;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date=datepart(date);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;end;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;format birth_date disease_status_date investigation_status_date diagnosis_date onset_date &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; event_create_date event_modification_date mmddyy10.;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;*-- create variable for first THURSDAY after diagnosis date;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;fthursDiag=diagnosis_date;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; weekday(fthursDiag)=1 then fthursDiag = fthursDiag+4;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; weekday(fthursDiag)=2 then fthursDiag = fthursDiag+3;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; weekday(fthursDiag)=3 then fthursDiag = fthursDiag+2;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; weekday(fthursDiag)=4 then fthursDiag = fthursDiag+1;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; weekday(fthursDiag)=5 then fthursDiag = fthursDiag+0;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; weekday(fthursDiag)=6 then fthursDiag = fthursDiag+6;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; weekday(fthursDiag)=7 then fthursDiag = fthursDiag+5;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;format birth_date diagnosis_date fthursDiag mmddyy10.;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;*-- try to restrict data using the newly calculated variable;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;where fthursDiag &amp;lt;= date();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 15:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107893#M258678</guid>
      <dc:creator>aklr86</dc:creator>
      <dc:date>2012-10-26T15:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Basic data step question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107894#M258679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From the documentation (&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000202951.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000202951.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000202951.htm&lt;/A&gt; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial, 'Arial Unicode MS', geneva, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;You cannot use variables that are created within the DATA step (for example, FIRST.&lt;/SPAN&gt;&lt;SPAN class="strong" style="font-family: arial, 'Arial Unicode MS', geneva, 'Lucida Grande', sans-serif; font-weight: bold; color: #000000; background-color: #ffffff;"&gt;variable&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, 'Arial Unicode MS', geneva, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;, LAST.&lt;/SPAN&gt;&lt;SPAN class="strong" style="font-family: arial, 'Arial Unicode MS', geneva, 'Lucida Grande', sans-serif; font-weight: bold; color: #000000; background-color: #ffffff;"&gt;variable&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, 'Arial Unicode MS', geneva, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;, _N_, or variables that are created in assignment statements) in a WHERE expression because the WHERE statement is executed before the SAS System brings observations into the DATA or PROC step. When WHERE expressions contain comparisons, the unformatted values of variables are compared.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, you could get around that by using and if statement in place of your current where statement.&amp;nbsp; However, in looking at your code, shouldn't your current if statements really be a set of if, then, else statements as well?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 15:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107894#M258679</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-10-26T15:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Basic data step question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107895#M258680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"However, in looking at your code, shouldn't your current if statements really be a set of if, then, else statements as well?" I don't understand this. Could you be more explicit?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 15:22:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107895#M258680</guid>
      <dc:creator>aklr86</dc:creator>
      <dc:date>2012-10-26T15:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Basic data step question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107896#M258681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to restrict the OUTPUT data to those records with the stated condition use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF&amp;nbsp; fthursDiag &amp;lt;= date();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you only want to make ONE change to the fthursDiag variable try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select (weekday(fthursDiag));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (1) fthursDiag = fthursDiag+4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (2) fthursDiag = fthursDiag+3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (3) fthursDiag = fthursDiag+2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (4) fthursDiag = fthursDiag+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (5) fthursDiag = fthursDiag+0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (6) fthursDiag = fthursDiag+6;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (7) fthursDiag = fthursDiag+5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 15:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107896#M258681</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-10-26T15:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Basic data step question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107897#M258682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you don't use the construction that &lt;A __default_attr="260198" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; recommended, or precede the 2nd thru 7th if statements with an 'else', the variable will be re-evaluated 7 times and each time using the value that resulted from the previous statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 16:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-data-step-question/m-p/107897#M258682</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-10-26T16:55:40Z</dc:date>
    </item>
  </channel>
</rss>

