Hello,
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.
This is the error I receive
49 25AUG2019
__
22
76
ERROR 22-322: Expecting a name.
I guess due to the rules that apply for naming - http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm
Is there a workaround to achieve what I want?
This is my code
%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 &oldForecastDate,
B.quantity as &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 = "&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 = "&newForecastDate"d
) AS B
WHERE A.matnum = B.matnum AND A.fc_mon = B.fc_mon
;
QUIT;
I tried using validvarname=any but this didn't help.