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....
Change the name in the filename statement so that it is 8 characters or less. Thus, instead of political, try it with politic.
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?
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!
Change the name in the filename statement so that it is 8 characters or less. Thus, instead of political, try it with politic.
It works after I changed the name into politic. Thanks a lot!!
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
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!
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.