BookmarkSubscribeRSS Feed
saurabh_latrobe
Fluorite | Level 6

I am quite new to SAS. I am trying to import a daily frequency dataset (via left join) into another dataset which has quarterly frequency data. The daily data has multiple observations in a single day.

I have written the below code but I am getting the error - "ERROR 78-322: Expecting a ','.

proc sql;
create table Try.finalmerge as
select distinct a.*, mean(b.ret5y) as ret_5y_qtr_mean /* calculate the average return*/, 
                     N(b.ret5y) as ret_5Y_qtr_count /* count the no of obs for return within a quarter */   
from Try.file1 a left join Try.file2 b 
on a.Code = b.Code /* same firm*/ and a.Date < b.Date and intnx('month', a.Date, 3, 'E') >= b.Date 
/* this condition requires that the obs in the file2 data file should have the date greater than the date in file1 data (quarter end date) 
   and the date less than or equal to the end of the next quarter */  
group by a.Code, a.Date /* calculate the average and count for ret for each code in each year-quarter */  
order by a.Code, a.Date ; /* sorting*/
quit;
7 REPLIES 7
saurabh_latrobe
Fluorite | Level 6
Thanks a lot for the response. i have copied the log file.
saurabh_latrobe
Fluorite | Level 6
                                                        The SAS System                         17:16 Thursday, September 17, 2020

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='';
6          %LET _CLIENTPROJECTPATHHOST='';
7          %LET _CLIENTPROJECTNAME='';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HTMLBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         libname Thesis1 "D:\Thesis Data\Pilot Data\Thesis Paper 1";
NOTE: Libref THESIS1 was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: D:\Thesis Data\Pilot Data\Thesis Paper 1
26       !                                                            /* Insert custom code before submitted code here */
27         


28         proc sql;
29         create table Try.finalmerge as
30         select distinct a.*, mean(b.ret5y) as ret_5y_qtr_mean /* calculate the average return*/, 
31                              N(b.ret5y) as ret_5Y_qtr_count /* count the no of obs for return within a quarter */
32         from Try.file1 a left join Try.file2 b
                                                 _
                                                 78
ERROR 78-322: Expecting a ','.

33         on a.Code = b.Code /* same firm*/ and a.Date < b.Date and intnx('month', a.Date, 3, 'E') >= b.Date
34         /* this condition requires that the obs in the ret data file should have the date greater than the date in climate change
34       !  data (quarter end date)
35            and the date less than or equal to the end of the next quarter */
36        group by a.Code, a.Date /* calculate the average and count for ret for each code in each year-quarter */  
order by a.Code, a.Date ; /* sorting*/
38         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
39         
2                                                          The SAS System                         17:16 Thursday, September 17, 2020

40         
41         GOPTIONS NOACCESSIBLE;
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         
yabwon
Onyx | Level 15

did you tried with adding `AS`

from Try.file1 AS a left join Try.file2 AS b

?

 

Bart 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



saurabh_latrobe
Fluorite | Level 6

I tried that as well but I get new errors in that case -

ERROR 22-322: Syntax error, expecting one of the following: ;, ',', ANSIMISS, CROSS, EXCEPT, FULL, GROUP, HAVING, INNER, INTERSECT,
JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT, UNION, WHERE.

ERROR 201-322: The option is not recognized and will be ignored.

yabwon
Onyx | Level 15
Maybe you have some unprintable character in your code behind that `b`?
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1293 views
  • 0 likes
  • 3 in conversation