<?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: How do I designate specific character variables date intervals using if...then statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-designate-specific-character-variables-date-intervals/m-p/738286#M230265</link>
    <description>&lt;P&gt;I am not sure what you are asking about.&lt;/P&gt;
&lt;P&gt;The code you posted appears to be creating two variables, but if either one already exists in&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;eclrsvs_fludata_new_NoDupkey&lt;/FONT&gt; then their type (and storage length) has already been defined and cannot be changed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want to explicit about how&amp;nbsp;&lt;FONT face="courier new,courier"&gt;death_date&lt;/FONT&gt; or&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Week_No&amp;nbsp;&lt;/FONT&gt; is defined then define them before using them in your assignment statements.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also why are you comparing date values (which are integers) to the results of those division expressions in your IF conditions?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want to compare a date value to a specific date you can use a date literal instead.&amp;nbsp; &amp;nbsp;Date literals are quoted strings that can be converted to a date by the DATE informat followed by the letter D.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.date_of_Death;
  set work.eclrsvs_fludata_new_NoDupkey;
  length death_date 8 Week_No $4 ;
  death_date=input(Dt_Of_death,yymmdd10.);
  format death_date mmddyy10.;
  if Death_date le '01AUG2020'd then Week_No = "2031";
  else if Death_date le '08AUG2020'd then Week_No = "2032";
  slse if Death_date le '15AUG2020'd then Week_No = "2033";
  else if Death_date le '22AUG2020'd then Week_No = "2034";
  else if Death_date le '29AUG2020'd then Week_No = "2035";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Apr 2021 23:06:36 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-04-30T23:06:36Z</dc:date>
    <item>
      <title>How do I designate specific character variables date intervals using if...then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-designate-specific-character-variables-date-intervals/m-p/738284#M230264</link>
      <description>&lt;P&gt;I am trying to designate character variables to specific date intervals yet it only produces numerical and does not read quoted statements. I did create a new date variable and was going to do the designations. Please help. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.date_of_Death;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.eclrsvs_fludata_new_NoDupkey;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;death_date=input(Dt_Of_death,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;yymmdd10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; death_date &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;mmddyy10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Death_date le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;08&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;01&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2020&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Week_No = &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"2031"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;Else&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Death_date le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;08&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;08&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2020&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Week_No = &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"2032"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;Else&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Death_date le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;08&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;15&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2020&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Week_No = &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"2033"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;Else&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Death_date le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;08&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;22&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2020&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Week_No = &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"2034"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;Else&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Death_date le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;08&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;29&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2020&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Week_No = &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"2035"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 22:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-designate-specific-character-variables-date-intervals/m-p/738284#M230264</guid>
      <dc:creator>ishaqwright21o</dc:creator>
      <dc:date>2021-04-30T22:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I designate specific character variables date intervals using if...then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-designate-specific-character-variables-date-intervals/m-p/738286#M230265</link>
      <description>&lt;P&gt;I am not sure what you are asking about.&lt;/P&gt;
&lt;P&gt;The code you posted appears to be creating two variables, but if either one already exists in&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;eclrsvs_fludata_new_NoDupkey&lt;/FONT&gt; then their type (and storage length) has already been defined and cannot be changed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want to explicit about how&amp;nbsp;&lt;FONT face="courier new,courier"&gt;death_date&lt;/FONT&gt; or&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Week_No&amp;nbsp;&lt;/FONT&gt; is defined then define them before using them in your assignment statements.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also why are you comparing date values (which are integers) to the results of those division expressions in your IF conditions?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want to compare a date value to a specific date you can use a date literal instead.&amp;nbsp; &amp;nbsp;Date literals are quoted strings that can be converted to a date by the DATE informat followed by the letter D.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.date_of_Death;
  set work.eclrsvs_fludata_new_NoDupkey;
  length death_date 8 Week_No $4 ;
  death_date=input(Dt_Of_death,yymmdd10.);
  format death_date mmddyy10.;
  if Death_date le '01AUG2020'd then Week_No = "2031";
  else if Death_date le '08AUG2020'd then Week_No = "2032";
  slse if Death_date le '15AUG2020'd then Week_No = "2033";
  else if Death_date le '22AUG2020'd then Week_No = "2034";
  else if Death_date le '29AUG2020'd then Week_No = "2035";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 23:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-designate-specific-character-variables-date-intervals/m-p/738286#M230265</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-30T23:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I designate specific character variables date intervals using if...then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-designate-specific-character-variables-date-intervals/m-p/738299#M230276</link>
      <description>&lt;P&gt;Here another option for calculating week_no:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.eclrsvs_fludata_new_NoDupkey;
  do _dt='01aug2020'd, '02aug2020'd,'01Jul2020'd to '20Sep2020'd by 5;
    Dt_Of_death=put(_dt,yymmdd10.);
    output;
  end;
  drop _dt;
  stop;
run;

data work.date_of_Death;
  set work.eclrsvs_fludata_new_NoDupkey;
  length death_date 8 Week_No $4;
  death_date=input(Dt_Of_death,yymmdd10.);

  format death_date mmddyy10.;
  retain _base_dt;
  format _base_dt date9.;
  if _n_=1 then _base_dt=intnx('week','01AUG2020'd,-2031,'b');
  week_no=put(intck('week',_base_dt,death_date), z4.);
/*  drop _base_dt;*/
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 May 2021 04:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-designate-specific-character-variables-date-intervals/m-p/738299#M230276</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-05-01T04:50:23Z</dc:date>
    </item>
  </channel>
</rss>

