BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robby_beum
Quartz | Level 8

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Jay_TxOAG
Quartz | Level 8

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

View solution in original post

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

EG keeps the space.

changing where Service_Date >= '01MAR2012'd;

to

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

ballardw
Super User

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

Ksharp
Super User

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

OR

use proc content check what variable name it truely contains .

Ksharp

Jay_TxOAG
Quartz | Level 8

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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