Hello there,
I am facing an error issue while running the PROC REG. My dataset(attached) named DSET1 have the following structure of rows and columns: ID, DATE Y and X with the format:
I have inserted the code and the full log here. I need help to run the regression for my dataset that contains data from Jan1990 - Dec2019 for each ID.
/** Import an XLSX file. **/
PROC IMPORT DATAFILE="H:\DSET1.xlsx\"
OUT=WORK.dset1
DBMS=XLSX
REPLACE;
RUN;
/** Print the results. **/
PROC PRINT DATA=WORK.dset1; RUN;
/** SortedIn ID & Date order**/
proc sort data=WORK.dset1 out=temp;
by id date;
run;
/** list of variables and attributes **/
Proc Contents data=work.temp;
run;
/** Estimate coefficients for each ID **/
proc reg noprint data=temp outest=regout1 edf ;
where Date between ‘01JAN2020’d and ‘31DEC1989’d;
model y = x;
by id;
run;
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 72 73 /** Import an XLSX file. **/ 74 75 PROC IMPORT DATAFILE="H:\Paper 3 SAS - Single Share Class\SAS MAcro help docs\DSET1.xlsx\" 76 OUT=WORK.dset1 77 DBMS=XLSX 78 REPLACE; 79 RUN; NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with options MSGLEVEL=I. NOTE: The import data set has 1800 observations and 4 variables. NOTE: WORK.DSET1 data set was successfully created. NOTE: PROCEDURE IMPORT used (Total process time): real time 0.11 seconds cpu time 0.06 seconds 80 81 /** Print the results. **/ 82 83 PROC PRINT DATA=WORK.dset1; RUN; NOTE: There were 1800 observations read from the data set WORK.DSET1. NOTE: PROCEDURE PRINT used (Total process time): real time 2.22 seconds cpu time 2.18 seconds 84 85 /** SortedIn ID & Date order**/ 86 proc sort data=WORK.dset1 out=temp; 87 by id date; 88 run; NOTE: There were 1800 observations read from the data set WORK.DSET1. NOTE: The data set WORK.TEMP has 1800 observations and 4 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 89 90 /** Estimate coefficients for each ID **/ 91 92 proc reg noprint data=temp outest=regout1 edf ; 93 where Date between ‘01JAN2020’d and ‘31DEC1989’d; _ 22 76 ERROR: Syntax error while parsing WHERE clause. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, (, +, -, INPUT, NOT, PUT, ^, ~. ERROR 76-322: Syntax error, statement will be ignored. 94 model y = x; 95 by id; 96 run; WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure. NOTE: PROCEDURE REG used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.REGOUT1 may be incomplete. When this step was stopped there were 0 observations and 0 variables. WARNING: Data set WORK.REGOUT1 was not replaced because this step was stopped. 97 98 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 111
Regards,
Sara
where Date between ‘01JAN2020’d and ‘31DEC1989’d;
Your date constants are inside left and right quote marks. Put them inside regular straight quotation marks.
where Date between ‘01JAN2020’d and ‘31DEC1989’d;
Your date constants are inside left and right quote marks. Put them inside regular straight quotation marks.
Thanks, @JackHamilton for pointing out this, much appreciated. Regards,Sara
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.