<?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: Proc SQL and YEAR in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68115#M6791</link>
    <description>Just curious if you read my reply...the part about using the DATEPART function?  Here's an over-simplified test scenario for your consideration.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
1    data x;&lt;BR /&gt;
2      BeginDate = dhms(today(),2,2,2);&lt;BR /&gt;
3      format BeginDate datetime15.;&lt;BR /&gt;
4      putlog _all_;&lt;BR /&gt;
5      run;&lt;BR /&gt;
&lt;BR /&gt;
BeginDate=12MAR10:02:02 _ERROR_=0 _N_=1&lt;BR /&gt;
NOTE: The data set WORK.X has 1 observations and 1 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
6      proc sql noprint;&lt;BR /&gt;
7      select year(BeginDate) FORMAT=YEAR4. AS Calculation&lt;BR /&gt;
8      from x;&lt;BR /&gt;
NOTE: Invalid argument to function YEAR. Missing values may be generated.&lt;BR /&gt;
9      quit;&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
10&lt;BR /&gt;
11     proc sql noprint;&lt;BR /&gt;
12     select year(datepart(BeginDate)) FORMAT=YEAR4. AS Calculation&lt;BR /&gt;
13     from x;&lt;BR /&gt;
14     quit;&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Fri, 12 Mar 2010 22:01:47 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2010-03-12T22:01:47Z</dc:date>
    <item>
      <title>Proc SQL and YEAR</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68112#M6788</link>
      <description>I am having a problem with YEAR function in my Proc SQL. For some reason when I want variable (RentPer) which contains date and time, to only display Year portion of the variable my EG is not letting me do it?&lt;BR /&gt;
&lt;BR /&gt;
Are these two procedure compatible.</description>
      <pubDate>Fri, 12 Mar 2010 20:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68112#M6788</guid>
      <dc:creator>BigZ</dc:creator>
      <dc:date>2010-03-12T20:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL and YEAR</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68113#M6789</link>
      <description>Your post indicates that you have a DATETIME variable/value.  The DATETIME format does not support displaying only the year portion of the DATETIME value.  You must use either DATEPART to extract the date and display the year-information with a suitable SAS format or use the YEAR function and display the value.&lt;BR /&gt;
&lt;BR /&gt;
Future posts/replies with your SAS code (preferably as part of a SAS log) would be helpful with accurate feedback.  Check here (may want to bookmark as favorite) for forum content posting guidelines with certain characters: &lt;A href="http://support.sas.com/forums/thread.jspa?messageID=27609" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=27609&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 12 Mar 2010 20:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68113#M6789</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-12T20:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL and YEAR</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68114#M6790</link>
      <description>OK this is what I get as my log output when I run my Project in the EG.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
1          ;*';*";*/;quit;run;&lt;BR /&gt;
2          OPTIONS PAGENO=MIN;&lt;BR /&gt;
3          %LET _CLIENTTASKLABEL='Query Builder1';&lt;BR /&gt;
4          %LET _CLIENTPROJECTPATH='C:\Documents and Settings\zahiroviczl\My Documents\SAS\First&lt;BR /&gt;
4        ! Projcet-Admitions.egp';&lt;BR /&gt;
5          %LET _CLIENTPROJECTNAME='First Projcet-Admitions.egp';&lt;BR /&gt;
6          &lt;BR /&gt;
7          ODS _ALL_ CLOSE;&lt;BR /&gt;
8          OPTIONS DEV=ACTIVEX;&lt;BR /&gt;
NOTE: Procedures may not support all options or statements for all devices. For details, see the &lt;BR /&gt;
      documentation for each procedure.&lt;BR /&gt;
9          GOPTIONS XPIXELS=0 YPIXELS=0;&lt;BR /&gt;
10         FILENAME EGSR TEMP;&lt;BR /&gt;
11         ODS tagsets.sasreport12(ID=EGSR) FILE=EGSR STYLE=Analysis&lt;BR /&gt;
11       ! STYLESHEET=(URL="file:///C:/Program%20Files/SAS/SharedFiles/BIClientStyles/4.2/Analysis.css&lt;BR /&gt;
11       ! ") NOGTITLE NOGFOOTNOTE GPATH=&amp;amp;sasworklocation ENCODING=UTF8 options(rolap="on");&lt;BR /&gt;
NOTE: Writing TAGSETS.SASREPORT12(EGSR) Body file: EGSR&lt;BR /&gt;
12         &lt;BR /&gt;
13         GOPTIONS ACCESSIBLE;&lt;BR /&gt;
14         %_eg_conditional_dropds(WORK.QUERY_FOR_RST09_NAICS_0000);&lt;BR /&gt;
NOTE: Table WORK.QUERY_FOR_RST09_NAICS_0000 has been dropped.&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
      &lt;BR /&gt;
&lt;BR /&gt;
15         &lt;BR /&gt;
16         PROC SQL;&lt;BR /&gt;
17            CREATE TABLE WORK.QUERY_FOR_RST09_NAICS_0000 AS&lt;BR /&gt;
18            SELECT t1.LegalName,&lt;BR /&gt;
19                   t1.TradeName,&lt;BR /&gt;
20                   t1.NAICS,&lt;BR /&gt;
21                   t3.RtnTotalSales,&lt;BR /&gt;
22                   t3.RtnTaxCollectable,&lt;BR /&gt;
23                   t3.RtnDueDate,&lt;BR /&gt;
24                   /* Calculation */&lt;BR /&gt;
25                     (YEAR(t3.PeriodBegin)) FORMAT=YEAR4. AS Calculation&lt;BR /&gt;
26               FROM WORK.QUERY_FOR_RST09_NAICS AS t1, HST.RST09_PAYMENTS AS t2, HST.RST09_RETURNS AS&lt;BR /&gt;
26       !  t3&lt;BR /&gt;
27               WHERE (t1.AccountKey = t2.AccountKey AND t1.AccountKey = t3.AccountKey) AND t1.NAICS&lt;BR /&gt;
27       ! IN ('711111', '711112',&lt;BR /&gt;
28                    '711190', '711311', '711512');&lt;BR /&gt;
NOTE: Invalid argument to function YEAR. Missing values may be generated.&lt;BR /&gt;
NOTE: Table WORK.QUERY_FOR_RST09_NAICS_0000 created, with 24205 rows and 7 columns.&lt;BR /&gt;
&lt;BR /&gt;
29         QUIT;&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           1:10.86&lt;BR /&gt;
      cpu time            11.87 seconds&lt;BR /&gt;
      &lt;BR /&gt;
&lt;BR /&gt;
30         &lt;BR /&gt;
31         &lt;BR /&gt;
2                                           The SAS System                15:07 Friday, March 12, 2010&lt;BR /&gt;
&lt;BR /&gt;
32         GOPTIONS NOACCESSIBLE;&lt;BR /&gt;
33         &lt;BR /&gt;
34         &lt;BR /&gt;
35         &lt;BR /&gt;
36         &lt;BR /&gt;
37         %LET _CLIENTTASKLABEL=;&lt;BR /&gt;
38         %LET _CLIENTPROJECTPATH=;&lt;BR /&gt;
39         %LET _CLIENTPROJECTNAME=;&lt;BR /&gt;
40         &lt;BR /&gt;
41         ;*';*";*/;quit;run;&lt;BR /&gt;
42         ODS _ALL_ CLOSE;&lt;BR /&gt;
43         &lt;BR /&gt;
44         &lt;BR /&gt;
45         QUIT; RUN;&lt;BR /&gt;
46</description>
      <pubDate>Fri, 12 Mar 2010 20:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68114#M6790</guid>
      <dc:creator>BigZ</dc:creator>
      <dc:date>2010-03-12T20:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL and YEAR</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68115#M6791</link>
      <description>Just curious if you read my reply...the part about using the DATEPART function?  Here's an over-simplified test scenario for your consideration.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
1    data x;&lt;BR /&gt;
2      BeginDate = dhms(today(),2,2,2);&lt;BR /&gt;
3      format BeginDate datetime15.;&lt;BR /&gt;
4      putlog _all_;&lt;BR /&gt;
5      run;&lt;BR /&gt;
&lt;BR /&gt;
BeginDate=12MAR10:02:02 _ERROR_=0 _N_=1&lt;BR /&gt;
NOTE: The data set WORK.X has 1 observations and 1 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
6      proc sql noprint;&lt;BR /&gt;
7      select year(BeginDate) FORMAT=YEAR4. AS Calculation&lt;BR /&gt;
8      from x;&lt;BR /&gt;
NOTE: Invalid argument to function YEAR. Missing values may be generated.&lt;BR /&gt;
9      quit;&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
10&lt;BR /&gt;
11     proc sql noprint;&lt;BR /&gt;
12     select year(datepart(BeginDate)) FORMAT=YEAR4. AS Calculation&lt;BR /&gt;
13     from x;&lt;BR /&gt;
14     quit;&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 12 Mar 2010 22:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68115#M6791</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-12T22:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL and YEAR</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68116#M6792</link>
      <description>Thanks Scott. &lt;BR /&gt;
It worked perfectly.</description>
      <pubDate>Mon, 15 Mar 2010 17:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-and-YEAR/m-p/68116#M6792</guid>
      <dc:creator>BigZ</dc:creator>
      <dc:date>2010-03-15T17:20:42Z</dc:date>
    </item>
  </channel>
</rss>

