BookmarkSubscribeRSS Feed
Emoji
Fluorite | Level 6

Sorry for posting my question again but the previous post does not let me to reply to the comments:

Here is my code and error that I get:

Thanks for your help. Please see the entire code and log below:

 

Code:

%LET DAYS= %EVAL( %SYSFUNC(INTNX(QTR,'01JAN2022'D, (&LOOP-1), E))-%SYSFUNC(INTNX(QTR,'01JAN2022'D, (&LOOP-1), B)) + 1);
%LET QUARTER_DAY_START = %SYSFUNC(DEQUOTE(" '%SYSFUNC(INTNX(MONTH, '01JAN2022'D, (&LOOP-1)*3, B), DATE11.)' "));
%LET QUARTER_DAY_END = %SYSFUNC(DEQUOTE(" '%SYSFUNC(INTNX(MONTH, '01JAN2022'D, ((&LOOP-1)*3)+ 2, E), DATE11.)' "));
%LET QUARTER_START_DATE = %SYSFUNC(INTNX(QTR,'01JAN2022'D,0,B));
%LET QUARTER_END_DATE = %SYSFUNC(INTNX(QTR,'01JAN2022'D,0,E));
%PUT &=DAYS;
%PUT &=QUARTER_DAY_START;
%PUT &=QUARTER_DAY_END;

DATA MY_NEW_TABLE;
SET WORK.MY_OLD_TABLE;
date = intnx('qtr','01jan2022'd,qtr-1,'b') to intnx('qtr','01jan2022'd,qtr-1,'e');
RUN;

 

Log:

1 The SAS System 06:13 Tuesday, December 13, 2022

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program 3';
4 %LET _CLIENTPROCESSFLOWNAME='Standalone Not In Project';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=SVG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 %macro HTML5AccessibleGraphSupported;
15 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16 %mend;
17 FILENAME EGHTML TEMP;
18 ODS HTML5(ID=EGHTML) FILE=EGHTML
19 OPTIONS(BITMAP_MODE='INLINE')
20 %HTML5AccessibleGraphSupported
MPRINT(HTML5ACCESSIBLEGRAPHSUPPORTED): ACCESSIBLE_GRAPH
21 ENCODING='utf-8'
22 STYLE=HtmlBlue
23 NOGTITLE
24 NOGFOOTNOTE
25 GPATH=&sasworklocation
26 ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27
28 %LET DAYS= %EVAL( %SYSFUNC(INTNX(QTR,'01JAN2022'D, (&LOOP-1), E))-%SYSFUNC(INTNX(QTR,'01JAN2022'D, (&LOOP-1), B)) + 1)
28 ! ;
29 %LET QUARTER_DAY_START = %SYSFUNC(DEQUOTE(" '%SYSFUNC(INTNX(MONTH, '01JAN2022'D, (&LOOP-1)*3, B), DATE11.)' "));
30 %LET QUARTER_DAY_END = %SYSFUNC(DEQUOTE(" '%SYSFUNC(INTNX(MONTH, '01JAN2022'D, ((&LOOP-1)*3)+ 2, E), DATE11.)' "));
31 %LET QUARTER_START_DATE = %SYSFUNC(INTNX(QTR,'01JAN2022'D,0,B));
32 %LET QUARTER_END_DATE = %SYSFUNC(INTNX(QTR,'01JAN2022'D,0,E));
33 %PUT &=DAYS;
DAYS=90
34 %PUT &=QUARTER_DAY_START;
QUARTER_DAY_START='01-JAN-2022'
35 %PUT &=QUARTER_DAY_END;
QUARTER_DAY_END='31-MAR-2022'
36
37
37 ! DATA MY_NEW_TABLE;
38 SET WORK.MY_OLD_TABLE ;
39 date = intnx('qtr','01jan2022'd,qtr-1,'b') to intnx('qtr','01jan2022'd,qtr-1,'e');
__
22
202
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT,
IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

40 RUN;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MY_NEW_TABLE may be incomplete. When this step was stopped there were 0 observations and 5 variables.
2 The SAS System 06:13 Tuesday, December 13, 2022

NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

41
42 %LET _CLIENTTASKLABEL=;
43 %LET _CLIENTPROCESSFLOWNAME=;
44 %LET _CLIENTPROJECTPATH=;
45 %LET _CLIENTPROJECTPATHHOST=;
46 %LET _CLIENTPROJECTNAME=;
47 %LET _SASPROGRAMFILE=;
48 %LET _SASPROGRAMFILEHOST=;
49
50 ;*';*";*/;quit;run;
51 ODS _ALL_ CLOSE;
52
53
54 QUIT; RUN;
55

5 REPLIES 5
russt_sas
SAS Employee

What are you trying to do with this statement because the 'TO' is not valid here:

  date = intnx('qtr','01jan2022'd,qtr-1,'b') to intnx('qtr','01jan2022'd,qtr-1,'e');

 

With separate assignment statements it works:
  date1 = intnx('qtr','01jan2022'd,qtr-1,'b');
  date2= intnx('qtr','01jan2022'd,qtr-1,'e');

Reeza
Super User
%LET DAYS= %EVAL( %SYSFUNC(INTNX(QTR,'01JAN2022'D, (&LOOP-1), E))-%SYSFUNC(INTNX(QTR,'01JAN2022'D, (&LOOP-1), B)) + 1);
%LET QUARTER_DAY_START = %SYSFUNC(DEQUOTE(" '%SYSFUNC(INTNX(MONTH, '01JAN2022'D, (&LOOP-1)*3, B), DATE11.)' "));
%LET QUARTER_DAY_END = %SYSFUNC(DEQUOTE(" '%SYSFUNC(INTNX(MONTH, '01JAN2022'D, ((&LOOP-1)*3)+ 2, E), DATE11.)' "));
%LET QUARTER_START_DATE = %SYSFUNC(INTNX(QTR,'01JAN2022'D,0,B));
%LET QUARTER_END_DATE = %SYSFUNC(INTNX(QTR,'01JAN2022'D,0,E));
%PUT &=DAYS;
%PUT &=QUARTER_DAY_START;
%PUT &=QUARTER_DAY_END;

DATA MY_NEW_TABLE;
SET WORK.MY_OLD_TABLE;

do date = intnx('qtr','01jan2022'd,qtr-1,'b') to intnx('qtr','01jan2022'd,qtr-1,'e');
    output;
end;

RUN;
russt_sas
SAS Employee

Is this code giving you an error?

 

DATA MY_NEW_TABLE;
SET WORK.MY_OLD_TABLE;

do date = intnx('qtr','01jan2022'd,qtr-1,'b') to intnx('qtr','01jan2022'd,qtr-1,'e');
    output;
end;

RUN;
PaigeMiller
Diamond | Level 26

You still haven't explained what you are trying to do, as several people requested in the last thread.

 

Please explain what you are trying to do. I get the feeling you are going about this in a very difficult way, when simpler code would work, but since I don't know what you are trying to do, I cannot help at this point in time.

 

Also, several people in the earlier thread have pointed out that this is not valid SAS syntax

 

date = intnx('qtr','01jan2022'd,qtr-1,'b') to intnx('qtr','01jan2022'd,qtr-1,'e');

 

and they also pointed out that you might want the statement to begin with a DO

 

do date = intnx('qtr','01jan2022'd,qtr-1,'b') to intnx('qtr','01jan2022'd,qtr-1,'e');

 

 

although maybe that's not what you want, and again if you explained what you are trying to do, we could be more definitive in our advice.

 

Its almost as if we are talking and you're not listening.

--
Paige Miller
mkeintz
PROC Star

I second @PaigeMiller 's request for an explanation of what you are trying to do.   As it stands, I don't have any idea.

 

But the code presented has the earmarks of a hammer looking for a nail.  You might be offered a simpler alternative if we had a clearer idea of the objective.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 622 views
  • 3 likes
  • 5 in conversation