<?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 Creating dummy variables for single date observations in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638269#M21543</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some issues with creating dummy variables for single date observations. The code i run gives the value 1 for every observations in the dataset when running:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Setting new outlier;&lt;BR /&gt;if date='24Dec2016'&lt;BR /&gt;date='05Dec2013'&lt;BR /&gt;date='24Dec2017'&lt;BR /&gt;date='24Dec2014'&lt;BR /&gt;date='24Dec2015'&lt;BR /&gt;date='24Dec2019'&lt;BR /&gt;date='24Dec2018'&lt;BR /&gt;date='24Sep2012'&lt;BR /&gt;date='06Jul2015'&lt;BR /&gt;then doutlier1=1; else doutlier1=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Apr 2020 09:54:22 GMT</pubDate>
    <dc:creator>SAScph</dc:creator>
    <dc:date>2020-04-08T09:54:22Z</dc:date>
    <item>
      <title>Creating dummy variables for single date observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638269#M21543</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some issues with creating dummy variables for single date observations. The code i run gives the value 1 for every observations in the dataset when running:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Setting new outlier;&lt;BR /&gt;if date='24Dec2016'&lt;BR /&gt;date='05Dec2013'&lt;BR /&gt;date='24Dec2017'&lt;BR /&gt;date='24Dec2014'&lt;BR /&gt;date='24Dec2015'&lt;BR /&gt;date='24Dec2019'&lt;BR /&gt;date='24Dec2018'&lt;BR /&gt;date='24Sep2012'&lt;BR /&gt;date='06Jul2015'&lt;BR /&gt;then doutlier1=1; else doutlier1=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 09:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638269#M21543</guid>
      <dc:creator>SAScph</dc:creator>
      <dc:date>2020-04-08T09:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating dummy variables for single date observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638270#M21544</link>
      <description>&lt;P&gt;Your code "gives" nothing, because it is invalid syntax:&lt;/P&gt;
&lt;PRE&gt; 75         if date='24Dec2016'
 76         date='05Dec2013'
            ____
            22
 77         date='24Dec2017'
            ____
            22
 78         date='24Dec2014'
            ____
            22
 79         date='24Dec2015'
            ____
            22
 80         date='24Dec2019'
            ____
            22
 81         date='24Dec2018'
            ____
            22
 82         date='24Sep2012'
            ____
            22
 83         date='06Jul2015'
            ____
            22
 ERROR 22-322: Syntaxfehler, erwartet wird eines der folgenden: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, 
               GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.  
 
 84         then doutlier1=1; else doutlier1=0;
&lt;/PRE&gt;
&lt;P&gt;If you actually have code that runs without ERRORs, post that.&lt;/P&gt;
&lt;P&gt;To check if a date is in a given set of dates, use the IN operator:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input date yymmdd10.;
format date yymmddd10.;
if date in ('01jan2020'd,'08apr2020'd)
then doutlier = 1;
else doutlier = 0;
datalines;
2020-01-01
2020-01-02
2020-04-08
2020-04-09
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2020 10:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638270#M21544</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-08T10:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating dummy variables for single date observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638285#M21548</link>
      <description>&lt;P&gt;Dummy variables in the sense that you have multiple columns containing only 1 or 0 in each column, depending on the date?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;This can be done via PROC GLMMOD (and several other procedures, as explained &lt;A href="https://communities.sas.com/t5/SAS-Procedures/How-can-i-create-dummy-variables-How-can-i-change-my-code/m-p/404308#M66929" target="_self"&gt;here&lt;/A&gt;), so you don't have to invent code to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I feel compelled to add that for most analyses in SAS, you don't need to create DUMMY variables yourself, or via some PROC. Most analyses can be performed via a CLASS statement, in which SAS creates the dummy variables behind the scenes, so you don't need to create dummy variables at all. So what are you planning to do after you obtain your dummy variables?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 11:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638285#M21548</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-08T11:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating dummy variables for single date observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638326#M21552</link>
      <description>&lt;P&gt;Or perhaps&lt;/P&gt;
&lt;PRE&gt;doutlier = (date in ('01jan2020'd,'08apr2020'd) );&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2020 14:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-dummy-variables-for-single-date-observations/m-p/638326#M21552</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-08T14:25:50Z</dc:date>
    </item>
  </channel>
</rss>

