<?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 flag is not working if i check the differnce between dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327052#M72927</link>
    <description>&lt;P&gt;&lt;STRIKE&gt;&lt;/STRIKE&gt;i have the below data:&lt;/P&gt;
&lt;TABLE width="281"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;subj&lt;/TD&gt;
&lt;TD width="73"&gt;asdt&lt;/TD&gt;
&lt;TD width="80"&gt;svsstd_num&lt;/TD&gt;
&lt;TD width="64"&gt;flag&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;101&lt;/TD&gt;
&lt;TD&gt;2006-01-10&lt;/TD&gt;
&lt;TD&gt;28-dec-05&lt;/TD&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;2005-11-15&lt;/TD&gt;
&lt;TD&gt;12OCT2005&lt;/TD&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;2005-12-08&lt;/TD&gt;
&lt;TD&gt;07-nov-05&lt;/TD&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;103&lt;/TD&gt;
&lt;TD&gt;2006-01-05&lt;/TD&gt;
&lt;TD&gt;02-dec-05&lt;/TD&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;the svsstd_num date format ias 12OCT2005 however i am not able to make it in excel. but all the date in &amp;nbsp;&lt;SPAN&gt;svsstd_num is the same format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am using the below code;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data ae051;&lt;BR /&gt; set ae98;&lt;BR /&gt; svsstd_num=input(SVSTDTC,yymmdd10.);&lt;BR /&gt; format svsstd_num date9.;&lt;BR /&gt; if visit="Visit 2 (Baseline)" then do;&lt;BR /&gt; if ASTDT &amp;lt; svsstd_num then flag= "N";&lt;BR /&gt; else flag= "Y";&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;which is taking if visit is in visit2 then flag, but if we see the second observation the flag should be "N".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am not sure why it is not giving the right result.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jan 2017 14:19:15 GMT</pubDate>
    <dc:creator>vraj1</dc:creator>
    <dc:date>2017-01-24T14:19:15Z</dc:date>
    <item>
      <title>flag is not working if i check the differnce between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327052#M72927</link>
      <description>&lt;P&gt;&lt;STRIKE&gt;&lt;/STRIKE&gt;i have the below data:&lt;/P&gt;
&lt;TABLE width="281"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;subj&lt;/TD&gt;
&lt;TD width="73"&gt;asdt&lt;/TD&gt;
&lt;TD width="80"&gt;svsstd_num&lt;/TD&gt;
&lt;TD width="64"&gt;flag&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;101&lt;/TD&gt;
&lt;TD&gt;2006-01-10&lt;/TD&gt;
&lt;TD&gt;28-dec-05&lt;/TD&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;2005-11-15&lt;/TD&gt;
&lt;TD&gt;12OCT2005&lt;/TD&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;2005-12-08&lt;/TD&gt;
&lt;TD&gt;07-nov-05&lt;/TD&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;103&lt;/TD&gt;
&lt;TD&gt;2006-01-05&lt;/TD&gt;
&lt;TD&gt;02-dec-05&lt;/TD&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;the svsstd_num date format ias 12OCT2005 however i am not able to make it in excel. but all the date in &amp;nbsp;&lt;SPAN&gt;svsstd_num is the same format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am using the below code;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data ae051;&lt;BR /&gt; set ae98;&lt;BR /&gt; svsstd_num=input(SVSTDTC,yymmdd10.);&lt;BR /&gt; format svsstd_num date9.;&lt;BR /&gt; if visit="Visit 2 (Baseline)" then do;&lt;BR /&gt; if ASTDT &amp;lt; svsstd_num then flag= "N";&lt;BR /&gt; else flag= "Y";&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;which is taking if visit is in visit2 then flag, but if we see the second observation the flag should be "N".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am not sure why it is not giving the right result.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327052#M72927</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-01-24T14:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: flag is not working if i check the differnce between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327058#M72928</link>
      <description>&lt;P&gt;I am suer we have mentioned this several times previously. &amp;nbsp;Post your test data&amp;nbsp;&lt;STRONG&gt;in the form of a datastep&lt;/STRONG&gt;. &amp;nbsp;Follow this post if you don't know how to. &amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is very important to show dataset&amp;nbsp;&lt;STRONG&gt;structure&amp;nbsp;&lt;/STRONG&gt;as this also has a bearing on programming. &amp;nbsp;I would suspect, from what you have posted that astdt is character, and that will be less than the numeric date value (i.e. convert the string into ascii numbers, will be less than number of days since..).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, several other things mentioned before, use the code editor window - {i} or SAS run symbol to keep formatting on code, e.g:&lt;/P&gt;
&lt;PRE&gt;data ae051;
  set ae98;
  svsstd_num=input(svstdtc,yymmdd10.);
  format svsstd_num date9.;
  if visit="Visit 2 (Baseline)" then do;
    if astdt &amp;lt; svsstd_num then flag="N";
    else flag="Y";
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Note, visit is not in your test data, but I assume that check works fine.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327058#M72928</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-24T14:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: flag is not working if i check the differnce between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327061#M72929</link>
      <description>&lt;P&gt;Your example data does not match the data you use in the data step. Variable visit is missing, and astdt should probably be asdt.&lt;/P&gt;
&lt;P&gt;Please post correct example data &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;in a data step&lt;/A&gt;, so we don't have to type it ourselves.&lt;/P&gt;
&lt;P&gt;Also always post the log of the step that gives you problems.&lt;/P&gt;
&lt;P&gt;For the flag portion, look at this (I added an additional observation to test the case for "N"):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subj asdt :yymmdd10. svsstd_num :date9.;
format asdt svsstd_num yymmdd10.;
cards;
101 2006-01-10 28-dec-05
102 2005-11-15 12OCT2005
102 2005-12-08 07-nov-05
103 2006-01-05 02-dec-05
104 2006-01-05 06-jan-06
run;

data want;
set have;
if ASDT &amp;lt; svsstd_num
then flag = "N";
else flag = "Y";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327061#M72929</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-24T14:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: flag is not working if i check the differnce between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327266#M72992</link>
      <description>&lt;P&gt;attached is the sample dataset which i was trying and the code below&lt;/P&gt;
&lt;P&gt;data ani(keep=svsstd_num visit ASTDT flag);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set ae98;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;svsstd_num=input(SVSTDTC,yymmdd10.);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format ASTDT svsstd_num date9.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if visit="Visit 2 (Baseline)" then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ASTDT &amp;lt; svsstd_num then flag = "N";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else flag = "Y";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 07:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327266#M72992</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-01-25T07:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: flag is not working if i check the differnce between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327268#M72993</link>
      <description>&lt;P&gt;Oh.My.God.&lt;/P&gt;
&lt;P&gt;What is so hard to understand about this:&lt;/P&gt;
&lt;P&gt;"Please post correct example data &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;in a data step&lt;/A&gt;, so we don't have to type it ourselves."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I have to download the .zip, unpack it, copy the file to my SAS server, only to find out that my SAS can't open it because of version problems. Probably because you run a DBCS SAS.&lt;/P&gt;
&lt;P&gt;With a data step, a simple copy/paste from here to the EG code window would have sufficed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you intentionally rude, or just lazy, or what?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 07:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flag-is-not-working-if-i-check-the-differnce-between-dates/m-p/327268#M72993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-25T07:56:21Z</dc:date>
    </item>
  </channel>
</rss>

