<?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: Naming SQL columns as dates in format DDMMMYYY in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585726#M14376</link>
    <description>&lt;P&gt;Very simple. Use valid SAS names, e.g. start the names with an underline.&lt;/P&gt;
&lt;P&gt;This can be achieved simply by doing&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A.quantity as quantity_&amp;amp;oldForecastDate,&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you even get more meaningful variable names on top.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using a typical date &lt;EM&gt;value&lt;/EM&gt; as a variable &lt;EM&gt;name&lt;/EM&gt; would be suboptimal (I'm deliberately polite here) anyway, as it opens you up for all kinds of confusion in your programs.&lt;/P&gt;</description>
    <pubDate>Tue, 03 Sep 2019 08:57:24 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-09-03T08:57:24Z</dc:date>
    <item>
      <title>Naming SQL columns as dates in format DDMMMYYY</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585719#M14373</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a proc sql query that compares two sets of forecasts and would like the names of two columns to be dates in format "DDMMMYYYY" (like for instance 01SEP2019) but SAS complains this is not valid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the error I receive&lt;/P&gt;&lt;PRE&gt;49          25AUG2019
            __
            22
            76
ERROR 22-322: Expecting a name. &lt;/PRE&gt;&lt;P&gt;I guess due to the rules that apply for naming -&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a workaround to achieve what I want?&lt;/P&gt;&lt;P&gt;This is my code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let oldForecastDate = 25AUG2019;
%let newForecastDate = 01SEP2019;

PROC SQL;
CREATE TABLE WORK.MAT_MASTER_DETAILS AS 
SELECT distinct
  Matnum, 
  MatDesc,
  Segment as Category
FROM DATA.MATERIAL_MASTER
WHERE Segment IN (12, 46) ;
QUIT;


PROC SQL;
CREATE TABLE WORK.fcst_diff AS 
  SELECT 
  A.matnum,
  A.MatDesc,
  A.Category,
  A.fc_mon,
  A.quantity as &amp;amp;oldForecastDate,
  B.quantity as &amp;amp;newForecastDate,
  B.quantity - A.quantity as Diff,
  put((B.quantity - A.quantity)/B.quantity, percentn8.2) as Pers_Diff
FROM
  (SELECT A1.matnum, A2.MatDesc, A2.Category, A1.fc_mon, A1.quantity 
  FROM DATA.FORECAST as A1
  INNER JOIN
  (
  SELECT Matnum, MatDesc, Category FROM 
  WORK.HOME_MAT_MASTER_DETAILS
  ) AS A2 
  ON A1.matnum = A2.Matnum 
  AND date = "&amp;amp;oldForecastDate"d
  ) AS A
,
  (SELECT B1.matnum, B2.MatDesc, B2.Category, B1.fc_mon, B1.quantity
  FROM DATA.FORECAST as B1
  INNER JOIN 
  (
  SELECT Matnum, MatDesc, Category FROM 
  WORK.HOME_MAT_MASTER_DETAILS
  ) as B2 
  ON B1.matnum = B2.Matnum
  AND date = "&amp;amp;newForecastDate"d
  ) AS B
  WHERE A.matnum = B.matnum AND A.fc_mon = B.fc_mon
;
QUIT;&lt;/PRE&gt;&lt;P&gt;I tried using&amp;nbsp;validvarname=any but this didn't help.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 08:45:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585719#M14373</guid>
      <dc:creator>veneling</dc:creator>
      <dc:date>2019-09-03T08:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Naming SQL columns as dates in format DDMMMYYY</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585721#M14374</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282287"&gt;@veneling&lt;/a&gt;&amp;nbsp;hi and welcome to the SAS Communities &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best workaround I can think of is to find another name for your column. It is rarely (never) a good idea to structure data like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you insist on structuring your data like this though, a simple underscore in from of your variable names will save you.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 08:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585721#M14374</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-09-03T08:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Naming SQL columns as dates in format DDMMMYYY</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585726#M14376</link>
      <description>&lt;P&gt;Very simple. Use valid SAS names, e.g. start the names with an underline.&lt;/P&gt;
&lt;P&gt;This can be achieved simply by doing&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A.quantity as quantity_&amp;amp;oldForecastDate,&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you even get more meaningful variable names on top.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using a typical date &lt;EM&gt;value&lt;/EM&gt; as a variable &lt;EM&gt;name&lt;/EM&gt; would be suboptimal (I'm deliberately polite here) anyway, as it opens you up for all kinds of confusion in your programs.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 08:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585726#M14376</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-03T08:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Naming SQL columns as dates in format DDMMMYYY</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585728#M14377</link>
      <description>&lt;P&gt;Okay, perhaps I will go to this solution even though the description becomes a bit overloaded and I want it as neat as possible.&lt;/P&gt;&lt;P&gt;The only reason for trying to have date as column name is that after get the report I transpose it and the comparison is distinctively visible for the people that read it. Otherwise I wouldn't do that.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 09:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-SQL-columns-as-dates-in-format-DDMMMYYY/m-p/585728#M14377</guid>
      <dc:creator>veneling</dc:creator>
      <dc:date>2019-09-03T09:10:55Z</dc:date>
    </item>
  </channel>
</rss>

