Help using Base SAS procedures

ERROR: Variable Service_Date is not on file P01.DATETEST.

Accepted Solution Solved
Reply
Contributor
Posts: 72
Accepted Solution

ERROR: Variable Service_Date is not on file P01.DATETEST.

I'm using EG 4.3 that resides on a server and using PROC IMPORT to read in an excel spreedsheet. Note that there is a space between the heading name 'Service Date'.

Here is my data in an excel spreadsheet:

IDService Date
12/20/2012
22/20/2012
32/24/2012
42/28/2012
53/8/2012
63/6/2012
73/12/2012
83/22/2012
93/28/2012
103/29/2012

Here is my code to read in the above excel spreadsheet:

proc import out=P01.datetest

      datafile="\\Dhvswdphapp01\user\USERS\RBeum\SAS\Input\Excelcs_Date_test.xls"

      dbms=EXCELCS REPLACE;

      sheet="Sheet1";

      scantime=YES;

      SERVER='rvwsascpt01';

      PORT=9621;

run;

data P01.datetest_out;

      set P01.datetest;

      where Service_Date >= '01MAR2012'd;

run;

Here is the resulting error:

NOTE: The data set P01.DATETEST has 10 observations and 2 variables.

23        
24         
24       !  data P01.datetest_out;
25                set P01.datetest;
26                where Service_Date >= '01MAR2012'd;
ERROR: Variable Service_Date is not on file P01.DATETEST.
27             run;

NOTE: The SAS System stopped processing this step because of errors.
2                                The SAS System       09:30 Tuesday, May 1, 2012

WARNING: The data set P01.DATETEST_OUT may be incomplete.  When this step was
         stopped there were 0 observations and 2 variables.
WARNING: Data set P01.DATETEST_OUT was not replaced because this step was
         stopped.
NOTE: DATA statement used (Total process time):
      real time           0.12 seconds
      cpu time            0.00 seconds

It's my understanding that SAS replaces a SPACE with an underscore in column headings - is that correct?

Any ideas how to resolve with renaming the heading?


Accepted Solutions
Solution
‎05-02-2012 08:02 AM
Contributor
Posts: 45

Re: ERROR: Variable Service_Date is not on file P01.DATETEST.

If you set OPTIONS VALIDVARNAME=V7, you will get underscores in your variable names instead of blanks.

View solution in original post


All Replies
Super Contributor
Posts: 1,636

Re: ERROR: Variable Service_Date is not on file P01.DATETEST.

EG keeps the space.

changing where Service_Date >= '01MAR2012'd;

to

where "Service Date"n >= '01MAR2012'd;

Super User
Posts: 10,550

Re: ERROR: Variable Service_Date is not on file P01.DATETEST.

Or check to see if there are leading blanks and/or more than one blank between Service and Date.

Super User
Posts: 9,691

Re: ERROR: Variable Service_Date is not on file P01.DATETEST.

Did you open P01.datetest to see what variable names they are ?

OR

use proc content check what variable name it truely contains .

Ksharp

Solution
‎05-02-2012 08:02 AM
Contributor
Posts: 45

Re: ERROR: Variable Service_Date is not on file P01.DATETEST.

If you set OPTIONS VALIDVARNAME=V7, you will get underscores in your variable names instead of blanks.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 199 views
  • 3 likes
  • 5 in conversation