<?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: date in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492963#M3290</link>
    <description>&lt;P&gt;It works&lt;/P&gt;&lt;P&gt;Thank you so much for your help&lt;/P&gt;</description>
    <pubDate>Thu, 06 Sep 2018 11:23:47 GMT</pubDate>
    <dc:creator>Lok07</dc:creator>
    <dc:date>2018-09-06T11:23:47Z</dc:date>
    <item>
      <title>Error in date variable</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492656#M3274</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;SPAN&gt;community,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;i have a problem in creating a date variable&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for example i want to create a date variable from 1983 to 2017 using this code&lt;/P&gt;
&lt;PRE&gt;DATA datatime ;
   format date year4. ;
 
   do date=  '1983'd to '2017'd ; 
      output datatime ;
   end ;
run &lt;/PRE&gt;
&lt;P&gt;however, i face an error.&lt;/P&gt;
&lt;P&gt;thank&amp;nbsp;you for your helps&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 13:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492656#M3274</guid>
      <dc:creator>Lok07</dc:creator>
      <dc:date>2018-09-05T13:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492660#M3275</link>
      <description>&lt;P&gt;A SAS numeric date can only be all three components as it is a count of days since the cuttoff point.&amp;nbsp; 1983 is not a valid "date", it is just a number.&amp;nbsp; So you would need to create actual dates (doesn't matter what format you apply) and display it differently:&lt;/P&gt;
&lt;PRE&gt;data datatime (drop=i);
   format date year4.;
   do i=1983 to 2017; &lt;BR /&gt;      date=mdy(1,1,i);
      output;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;This will create 34 rows, one for each year with the date variable containing 01JAN for each year, the format then just shows the year part only (but if you remove the format you will see this).&lt;/P&gt;
&lt;P&gt;To be honest though you do not need to use a format, or a date, unless you really need to as:&lt;/P&gt;
&lt;PRE&gt;data datatime;
   do year=1983 to 2017; &lt;BR /&gt;       output;
   end;
run &lt;/PRE&gt;
&lt;P&gt;Is effectively the same.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 13:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492660#M3275</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-05T13:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492662#M3276</link>
      <description>&lt;P&gt;SAS Dates must include a day of the month and a month and a year. Yours only includes year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to use something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'01JAN1983'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA datatime ;
   do date=  1983 to 2017 ; 
      output datatime ;
   end ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 13:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492662#M3276</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-05T13:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492664#M3277</link>
      <description>&lt;P&gt;SAS dates represent a single day, so you need to supply a complete date if using date literals:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start=1983;
%let end=2017;

data datatime;
format date year4. ;
date = "01jan&amp;amp;start."d;
do until (date &amp;gt; "01jan&amp;amp;end."d);
  output datatime;
  date = intnx('year',date,1);
end;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Alternatively, using the iterative do loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datatime;
format date year4.;
do year = &amp;amp;start to &amp;amp;end;
  date = mdy(1,1,year);
  output;
end;
drop year;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Sep 2018 13:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492664#M3277</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-05T13:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error in date variable</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492675#M3278</link>
      <description>&lt;P&gt;You need to give date value&amp;nbsp;like&amp;nbsp;&lt;STRONG&gt;'01jan2018'd&lt;/STRONG&gt; instead of just '2018'd. When you give actual date values and need by each year you need to loop by year, for this you can use INTNX to go to next year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the below code you can also change the format for the date and also the loop to months or days instead of year.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA datatime ;
format date  year4.;
do date='01JAN1983'd to '31JAN2017'd;
output;
date=intnx('year',date,1,"b");
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to give numeric values instead of giving the actual dates then this might work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA datatime ;
format date  year4.;
do i=1983 to 2017;
date=input(cats("01jan",i),date9.);
output;
;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Sep 2018 14:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492675#M3278</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-09-05T14:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492797#M3282</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;i used your suggestion&lt;/P&gt;&lt;P&gt;but after creating the date variable i can't plot data&lt;/P&gt;&lt;P&gt;When i applied this code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; proc timeseries data=data out=series;
      id date interval=year;
      var date D;
   run;&lt;/PRE&gt;&lt;P&gt;i got only this table&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 20:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492797#M3282</guid>
      <dc:creator>Lok07</dc:creator>
      <dc:date>2018-09-05T20:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492903#M3285</link>
      <description>&lt;P&gt;And what exactly is it you want?&amp;nbsp; This new information has nothing to do with the original question.&amp;nbsp; For plots you specify plots on the proc line, and you need to have an ods destination open:&lt;BR /&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_timeseries_sect045.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_timeseries_sect045.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code you give doesn't seem to plot anything, just creates and output dataset of the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 08:01:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492903#M3285</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-06T08:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492907#M3286</link>
      <description>I want just verify if my variable was created or not.</description>
      <pubDate>Thu, 06 Sep 2018 08:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492907#M3286</guid>
      <dc:creator>Lok07</dc:creator>
      <dc:date>2018-09-06T08:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492913#M3288</link>
      <description>&lt;P&gt;Sorry, how does this post relate to "i used your suggestion but after creating the date variable i can't plot data"?&lt;/P&gt;
&lt;P&gt;If you want to see if a variable is created, you first check the log - which is your one source of the run - then you check the dataset.&amp;nbsp; We can only provide guidance&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;on the information you provide in the post&lt;/STRONG&gt;&lt;/U&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 08:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492913#M3288</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-06T08:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492924#M3289</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/224676"&gt;@Lok07&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I want just verify if my variable was created or not.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Inspect the log.&lt;/P&gt;
&lt;P&gt;Look at your dataset with the table viewer.&lt;/P&gt;
&lt;P&gt;Use proc contents.&lt;/P&gt;
&lt;P&gt;Use proc datasets.&lt;/P&gt;
&lt;P&gt;Retrieve information from dictionary.columns or sashelp.vcolumn.&lt;/P&gt;
&lt;P&gt;Do a proc print without the var statement.&lt;/P&gt;
&lt;P&gt;If the variable is present, run a proc freq to see the distribution of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need any more options?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 09:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492924#M3289</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-06T09:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: date</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492963#M3290</link>
      <description>&lt;P&gt;It works&lt;/P&gt;&lt;P&gt;Thank you so much for your help&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 11:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Error-in-date-variable/m-p/492963#M3290</guid>
      <dc:creator>Lok07</dc:creator>
      <dc:date>2018-09-06T11:23:47Z</dc:date>
    </item>
  </channel>
</rss>

