Search code examples
viewsasdatastep

Where is the syntax error within this SAS view code?


data work.temp work.error / view = work.temp;  
infile rawdata;  
input Xa Xb Xc;  
if Xa=. then output work.errors;  
else output work.temp;  
run;

It says there's a syntax error in the DATA statement, but I can't find where ...


Solution

  • The error is a typo in the OUTPUT statement. You are trying to write observations to ERRORS but the data statement only defined ERROR.

    It is a strange construct and not something I would recommend, but it looks like it will work. When you exercise the view TEMP it will also generate the dataset ERROR.

    67   data x; set temp; run;
    
    NOTE: The infile RAWDATA is:
          Filename=...
    
    NOTE: 2 records were read from the infile RAWDATA.
          The minimum record length was 5.
          The maximum record length was 5.
    NOTE: View WORK.TEMP.VIEW used (Total process time):
          real time           0.32 seconds
          cpu time            0.01 seconds
    
    NOTE: The data set WORK.ERROR has 1 observations and 3 variables.
    NOTE: There were 1 observations read from the data set WORK.TEMP.
    NOTE: The data set WORK.X has 1 observations and 3 variables.