Help using Base SAS procedures

proc import

Reply
Occasional Contributor
Posts: 9

proc import

Hi,

I am currently using SAS EG 4.2 and I get weird error on trying to run simple proc import :


proc import out = temp datafile = "C:\Users\Downloads\Temp.xls"
dbms = xls replace ;
sheet = combined;
run;

ERROR: Physical file does not exist

Would be great if you guys could help me with this.

Also, is there any way I could import all the tabs in my excel files into sas tables with name corresponding to each tab name ??



Thanks.
Super User
Posts: 9,676

Re: proc import

Hi.
The log displays ERROR: Physical file does not exist. maybe temp.xls is not the right path.


>Also, is there any way I could import all the tabs in my excel files into sas tables with name corresponding to each tab name ??


Sure.you need "libname x excel 'xxxx' " statement to assign a libname to excel file ,then use 'proc sql ......from dictionary.tables' to yield the sheet name in that xls file.then use %do macro .


Ksharp
Occasional Contributor
Posts: 9

Re: proc import

Thanks

I had one more question ...

The variable names I get after import are all having special characters like " : % ( ) , # .. however, I want the imported columns to follow the SAS variable naming convention is there any option for that ?? Message was edited by: rickw
Super User
Posts: 9,676

Re: proc import

Yes.
There is a system option ' options validvarname=any ' can use any special character for variable name (only available for Base and Stat).
If you do not want, can close it or change it.

Ksharp
Occasional Contributor
Posts: 9

Re: proc import

I actually meant that I want to follow the SAS naming rules that is having underscore instead of special characters ...

When I import the data it is not getting converted to variable naming convention this is just happening for excel files...

when I import csv files the variable names are following the SAS naming convention...

I tried options validvarname = v7..

but that gives some error ..

ERROR: The value Assigned To: Full Name is not a valid SAS name.

Thanks.
Super User
Posts: 9,676

Re: proc import

Hi.
I try it.
In fact, SAS will use your illegal variable name as label.And variable is actually converted successful.

If you add another options ' options nolabel ; ' then you will find SAS has already convert varname as the rule of V7.

Or use proc contents to see it deeply.


Ksharp
Ask a Question
Discussion stats
  • 5 replies
  • 243 views
  • 0 likes
  • 2 in conversation