Help using Base SAS procedures

Filename Statement

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Filename Statement

Can filename statment read extenal files in a disk other than C disk? if so, what is wrong with my code?

My code:"

filename political ('F:\Homework\SASDatafile\political.csv');

data Vote;
infile political dsd;
input State $ Party $ Age;
run;"

and the log:"

105  filename political ('F:\Homework\SASDatafile\political.csv');
ERROR: Invalid logical name.
ERROR: Error in the FILENAME statement.
106
107  data Vote;
108      infile political dsd;
109      input State $ Party $ Age;
110  run;

ERROR: Physical file does not exist, C:\Program Files\SAS\SAS 9.1\POLITICAL.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.VOTE may be incomplete.  When this step was stopped there were 0 observations and 3
         variables.
WARNING: Data set WORK.VOTE was not replaced because this step was stopped."

I am just a SAS beginner....


Accepted Solutions
Solution
‎09-25-2011 12:24 PM
PROC Star
Posts: 7,363

Filename Statement

  Change the name in the filename statement so that it is 8 characters or less.  Thus, instead of political, try it with politic.

View solution in original post


All Replies
PROC Star
Posts: 7,363

Filename Statement

It should work unless you've typed it incorrectly or have some imbedded spaces that you aren't showing in your code.  If there are imbedded spaces change the single quotes to double quotes.

Can you see the file, outside of SAS, using Windows Explorer?

Occasional Contributor
Posts: 6

Filename Statement

I can see the file in csv by excel. I double checked my code and am sure there is no imbedded spaces...

The thing here I cannot understand is that

"

ERROR: Invalid logical name.

ERROR: Error in the FILENAME statement." &

"

ERROR: Physical file does not exist, C:\Program Files\SAS\SAS 9.1\POLITICAL." in log file.

It seems that the SAS tried to find my file from C disk instead of F disk. Did it?

Many Thanks!

Solution
‎09-25-2011 12:24 PM
PROC Star
Posts: 7,363

Filename Statement

  Change the name in the filename statement so that it is 8 characters or less.  Thus, instead of political, try it with politic.

Occasional Contributor
Posts: 6

Filename Statement

It works after I changed the name into politic. Thanks a lot!!

PROC Star
Posts: 7,363

Filename Statement

And, for your reference, the maximum lengths of various names you can use in SAS are shown at:

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 7412 views
  • 8 likes
  • 2 in conversation