<?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: Adding intervention levels to dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/823650#M325236</link>
    <description>&lt;P&gt;Please look at your data set and then tell us some typical values of MONTH in data set SAMPLE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there really a value of &lt;FONT face="courier new,courier"&gt;'04187.'&lt;/FONT&gt; in the data set SAMPLE with a period at the end? What does &lt;FONT face="courier new,courier"&gt;'04187.'&lt;/FONT&gt; with a period at the end mean? What are you trying to compare month to? Please explain this part clearly.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Jul 2022 18:39:46 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-07-16T18:39:46Z</dc:date>
    <item>
      <title>Adding intervention levels to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/823648#M325235</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data mydata; 
	set sample;
    if month &amp;gt;= '04187.' then intervention1 = 1;
    else intervention1= 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with multiple intervention levels for which I am trying to run an interrupted time series analysis. I am trying to use 0 and 1 for each intervention to denote when the intervention started. I have the code for that listed above, but the selection for the&amp;nbsp;&lt;CODE class=""&gt;if month &amp;gt;= '04187.'&lt;/CODE&gt;&amp;nbsp;is not working. When I try to run this code, it's not that I get an error, but the intervention level I created is "1" throughout and not starting at the data April 2018. I've tried a whole bunch of variations for that date field but haven't been successful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how I have my date formatted below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data mydata; 
	set sample;
    time = put(time_period,6.);
    month = input(time, YYMMn6.);
  format month monyy7.;
  run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any thoughts for how to address this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 17:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/823648#M325235</guid>
      <dc:creator>mmaximos</dc:creator>
      <dc:date>2022-07-16T17:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Adding intervention levels to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/823650#M325236</link>
      <description>&lt;P&gt;Please look at your data set and then tell us some typical values of MONTH in data set SAMPLE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there really a value of &lt;FONT face="courier new,courier"&gt;'04187.'&lt;/FONT&gt; in the data set SAMPLE with a period at the end? What does &lt;FONT face="courier new,courier"&gt;'04187.'&lt;/FONT&gt; with a period at the end mean? What are you trying to compare month to? Please explain this part clearly.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 18:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/823650#M325236</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-16T18:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding intervention levels to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/823656#M325237</link>
      <description>&lt;P&gt;Month, if the code you show for the Mydata data step would be numeric in value. So you likely have conversion of character values such as in this example.&lt;/P&gt;
&lt;PRE&gt;87   data junk;
88      month= input('202205',yymmn6.);
89      put month= best12. month= monyy.;
90      format month monyy.;
91      if month &amp;gt;= '04187.' then intervention1 = 1;
92       else intervention1= 0;
93   run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      91:16&lt;BR /&gt;month=22766 month=MAY22&lt;BR /&gt;
&lt;/PRE&gt;
&lt;P&gt;IF your month is actually a date as implied by your input statement the values are being compared, in effect, to the the date of 27Jan1964. So if your generated date values are later than 27Jan1964 then the Intervention would obviously be 1. To compare DATE values to a specific date then use the form "ddMONyyyy"d&amp;nbsp; or '01Jan2022'd with the date in quotes followed by d. Nothing else is likely to convert properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are asking for all sorts of conversion confusion if you let SAS decide which way to play with things when you compare character and numeric values. It is best to take control and provide the conversion your self.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am a tad suspicious of your whole code for the Mydata data set as to if that step was done correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: the only form of date I would expect to be referenced with 5 digits is a Julian date but your value is out of range to considered as such.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 19:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/823656#M325237</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-16T19:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding intervention levels to dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/824225#M325477</link>
      <description>&lt;P&gt;Currently, the date field is numeric with a length of 8 and appears as such in the output as an example "201511". So as I understand, I need to convert that to a character value first and then to a SAS date. Is that correct?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My date field in my dataset is named time_period, so this is how I went about converting the date field in the initial dataset into a SAS date:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data mydata; 
	set sample;
    sasdate=input(time_period, yymmn6.);
    format sasdate monyy.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, that resulted in the sasdate column being "." all the way down (no distinct numbers from that Jan 1964 starting point). I think I am missing a step to convert that date field from numeric to character, but don't quite know how to fix this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 19:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-intervention-levels-to-dataset/m-p/824225#M325477</guid>
      <dc:creator>mmaximos</dc:creator>
      <dc:date>2022-07-19T19:15:36Z</dc:date>
    </item>
  </channel>
</rss>

