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

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....

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

  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

5 REPLIES 5
art297
Opal | Level 21

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?

ariel_fj
Fluorite | Level 6

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!

art297
Opal | Level 21

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

ariel_fj
Fluorite | Level 6

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

art297
Opal | Level 21

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 33380 views
  • 10 likes
  • 2 in conversation