- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi I am reading an example in SAS Essentials by Elliot (pg. 137) screenshot as follow
When I run the code without the two semicolons I circled, the result is exact the same as with the two circle semicolons.
the only difference is the there are two syntax error in the log
they are
What is the point of the two semicolon in the INPUT statement if SAS can generate the result them?
I thought the purpose of the semicolon is to close a statement, when the first semicolon exist, should it immediately terminate the input statement?
ERROR 22-322: Syntax error, expecting one of the following: a name, arrayname, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 76-322: Syntax error, statement will be ignored.
here is the code if anyone is interested
DATA DATES; INPUT @1 BDATE MMDDYY8.; TARGET=MDY(08,25,2009); * Uses MDY() function; AGE=INTCK('YEAR',BDATE,TARGET); * INTCK function; DATALINES; 07101952 07041776 01011900 ; PROC PRINT DATA=DATES; FORMAT BDATE WEEKDATE. TARGET MMDDYY8.; RUN;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That's exactly happens. The first semicolon terminates the input statement, the 2nd semicolon terminates code that assigns a value to a variable (this one has nothing to do with the input statement).
It can't. If you run your code in a fresh new SAS session without the semicolons then the target table won't get created. What you might see in your test is the "left over" from your first run with correct syntax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That's exactly happens. The first semicolon terminates the input statement, the 2nd semicolon terminates code that assigns a value to a variable (this one has nothing to do with the input statement).
It can't. If you run your code in a fresh new SAS session without the semicolons then the target table won't get created. What you might see in your test is the "left over" from your first run with correct syntax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
okay I think I fundamentally misunderstood the INPUT statement.
so if the variables data is not from DATALINES, then you don't need to use INPUT? You can simply define for example a constant variable without using INPUT before PROC MEANS/PRINT?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
From https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0oaql83drile0n141pdacojq97s.htm
Basically: The input statement is used to read EXTERNAL data into SAS VARIABLE.
Normally the INPUT statement is paired with the INFILE statement. The INFILE statement defines the external file (like where it's stored), and the input statement then reads the data.
DATALINES is for in-stream data (=data directly in the code) and though a bit of special case and normally only used to create some self-contained samples.
May-be reading below will create a bit more clarity for you.
And don't worry - just the normal confusion of a beginner. You'll get there. It's not that complicated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It definitely does NOT run the same if you convert three statements into one statement by removing the semicolons that end the first two statements.
686 DATA DATES; 687 INPUT @1 BDATE MMDDYY8.; 688 TARGET=MDY(08,25,2009); 689 * Uses MDY() function; 690 AGE=INTCK('YEAR',BDATE,TARGET); * INTCK function; 691 DATALINES; NOTE: The data set WORK.DATES has 3 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 695 ; 696 DATA DATES; 697 INPUT @1 BDATE MMDDYY8. 698 TARGET=MDY(08,25,2009) -- 22 76 ERROR 22-322: Syntax error, expecting one of the following: a name, arrayname, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 76-322: Syntax error, statement will be ignored. 699 * Uses MDY() function; 700 AGE=INTCK('YEAR',BDATE,TARGET); * INTCK function; 701 DATALINES; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DATES may be incomplete. When this step was stopped there were 0 observations and 4 variables. WARNING: Data set WORK.DATES was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 705 ;