02-20-2014 11:15 PM
I am trying to use enterprise guide 6.1 to import raw data files and excels files but I am having a bit of trouble doing so. I am attempting to do this without using the built in import features just by code alone. I am following the step by step procedure outlined in SAS Certification Prep Guide: Base Programming for SAS9 Third edition. My code is as follows:
LIBNAME work '/saswork/SAS_work96130000764A_oda01au/SAS_work67f0000764A_oda01au';
filename sampledata 'C:\Users\Lucas\Documents\data.txt';
infile sampledata obs=max;
input ID $ 1-4 Sex $ 5-7 Age 8-11
Height 12-17 Weight 18-23
proc print data=work.sampledata;
and these are the error messages I am receiving:
ERROR: The SAS system library WORK may not be reassigned.
ERROR: Error in the LIBNAME statement.
ERROR: Invalid logical name.
ERROR: Error in the FILENAME statement.
ERROR: Physical file does not exist, /pbr/biconfig/930/Lev1/SASApp/SAMPLEDATA.
Any help on the subject would be greatly appreciated and thank you for your time.
02-20-2014 11:28 PM
I don't have access to EG, thus will just take a guess at what your problem might be .. namely the use of the filename statement. Try this:
filename sampledataIN 'C:\Users\Lucas\Documents\data.txt';
infile sampledataIN obs=max;
input ID $ 1-4 Sex $ 5-7 Age 8-11
Height 12-17 Weight 18-23
proc print data=work.sampledata;
02-21-2014 09:02 AM
It is still coming up with an error in the filename statement. The log still says the that the file I am trying to access does not exist. It would seem based off of the error statement that it is referencing the wrong location. The error statement reads,"Physical file does not exist, /pbr/biconfig/930/Lev1/SASApp/SAMPLEDATA." Thank you for your help.
02-21-2014 09:18 AM
The NAME of a fileref must not be longer than 8 characters. If you will look closely, you will see that the filename statement generates an error (invalid logical name).
02-21-2014 11:09 AM
Kurt is definitely correct. There are specific limits to valid SAS names dependent upon what they are used for. Take a look at:
02-21-2014 05:02 PM
Thank you for the help but I am still having trouble where it says the physical file does not exist. In the error statement it refers to the file /pbr/biconfig/930/Lev1/SASApp/C:\Users\Lucas\Documents\data.txt. the latter half of this is the location of the .txt file I am not sure what this first part is.
02-21-2014 06:02 PM
This is one that comes up frequently with new Enterprise Guide users.
A key concept in EG is that although you are running EG on your windows desktop, the SAS software that is actually executing the SAS code may or may not be running on your desktop. Enterprise Guide is designed to work with SAS instances both on your desktop and on remote servers.
In your case, because you're receiving diagnostics with directory names that look like "/pbr/biconfig/930", I can tell you that your SAS code is running on a Unix server. That means that i) none of the datasets on your workstation will be available to SAS, and ii) you'll need to provide library and file references using Unix syntax instead of Windows.
First, there should be a SAS administrator at your organization (who installed and supports all this stuff), and they should be able to provide advice about how the environment is set up.
Second, here's a blog post from the brilliant Chris Hemedinger about how to move files from your workstation to the server:
(he pays me ten bucks every time I publicly call him brilliant)
Hang in there...soon you'll be helping out new users!
02-21-2014 10:21 PM
Second, I didn't say anything negative about EG (in this thread), just that I didn't have access to it when I responded. However, yes, you are probably right regarding the operating system. Not bad for a Senator!
02-22-2014 04:11 PM
Are you using SAS OnDemand for Professionals or SAS OnDemand for Academics? Or, does your system with SAS have an installation of the BI Platform. When you said you did not know what the location of the the path was:
/pbr/biconfig/930/Lev1/SASApp/C:\Users\Lucas\Documents\data.txt (where the red portion is the default path for the BI Config directory or OnDemand server directory and the blue portion is the location of your data on your C: drive).
The fact that the local path for the data file gets concatenated onto the default path for the server is a clue that the server isn't actually reading your C:\ drive and you need to move the data file to the server. The Lev1\SASApp directory is frequently a location associated with a BI Platform installation.
This is generally the kind of message you get when SAS is on a server machine (such as the OnDemand servers or a BI server) and your data is on your local C: drive and SAS (on the server) has no visibility of the data on your C: drive. In this case, as Tom suggests, you need to move the data files to your server. This is problematic if you are using the OnDemand server, because as it explains here (Commonly Asked Questions: support.sas.com) OnDemand students cannot load data onto the OnDemand server (see the question titled "Can I point to local SAS data sets or files using a LIBNAME or a FILENAME statement?"). However, if this is a different (work/school) usage of SAS, your SAS Admin should be able to help you get a write access location that SAS on the server can read.
02-22-2014 09:33 PM
I am using SAS OnDemand for Academics and unfortunately our school(Virginia Military Institute) does not use any SAS software and we use MATLAB exclusively. I am trying to get my base certification before I start my masters in business analytics at NCSU this summer and I am doing this on my own with a little help from one of my professors. SAS is just as new to him as it is to me. I am having to rely heavily on this forum to answer any questions when I have trouble translating what is in the SAS certification prep guide to the free EG that I was supplied with from the SAS OnDemand for Academics. Will I be encountering issues like this as I continue learning the base language? Thank you for your time and your help.
02-23-2014 07:39 PM
You ask "Will I be encountering issues like this as I continue learning the base language?" Well, maybe. You had 2 "issues" initially. One of your original "issues" was that you tried to read data from your C: drive. As I explained the error message that you got, because your Unix server path was prepended to your C: drive location was a clue that you were either using a SAS OnDemand server or you were working in a locked down BI Server configuration. This only was an issue because you are using the SAS OnDemand for Academics server. And when you came to the forum for help, people who did not realize this limitation made some suggestions, like uploading your data to the server that will not work for you. The information about not being able to read data from your C: drive was available to you in the Commonly Asked Questions web site (http://support.sas.com/ondemand/caq_new.html).
Another of your "issues" was that your FILENAME statement used a name that was too long (longer than 8 characters) and so, that "issue" was a rule that you should find in the Prep Guide. BTW, the Prep Guide is not meant to be your only study guide. The Base SAS Certification Prep Guide is meant primarily as a *refresher* for folks who have already taken Programming 1 and Programming 2 classes. And, they might have taken the classes a while ago and they need to refresh themselves before taking the certification exam. In the Programming 1 course, we talk about the limitations on the length of names that you use in the LIBNAME and FILENAME statements. Plus, Art sent you the documentation link. In my Prep Guide, on page 140, there is a note about the fact that the FILENAME statement should be 1-8 characters (see 2nd screen shot).
I do not know what is loaded on the SAS OnDemand for Academics server. When I use the SAS OnDemand for Professionals server, there is a BOOKDATA folder (under the FILES folder). The BOOKDATA folder contains all the data that students are intended to use when studying for the exam using the Prep Guide.
Every time you start a new job, you have new things to learn. What operating system are you using? How are you using SAS? What is your interface to SAS? What directories can you read from? What directories can you write to? What kind of data do you have? SAS data? Oracle data? DB2 data? CSV files? "Raw" data files? These are always "issues" that you will have whether you're using the Prep Guide or starting a new job or working with new data.
This "issue" you will have to live with while you are using SAS OnDemand for Academics -- that SAS on your server is running on a Unix operating system. Many of the examples in the Prep Guide show Windows syntax. So you might see something like this in the Prep Guide:
libname orion 'c:\workshop'; OR
filename mydata 'c:\workshop\classfit.dat';
but those locations won't work for you for 2 reasons:
1) SAS is on a UNIX server and doesn't have a C: drive and UNIX systems use / instead of \ in a path name and
2) You can't read data from your C: drive because you are using SAS OnDemand for Academics.
If you do have data on the server, then it might have a location like this:
/home/<yourusername>/bookdata/sas_cert_prep_guides/classfit.dat and then your filename statement might be:
filename mydata '/home/<yourusername>/bookdata/sas_cert_prep_guides/classfit.dat'; or
filename mydata '~/bookdata/sas_cert_prep_guides/tests.dat';
So, you have to figure out whether the data you need is already loaded on the OnDemand server. If you were working with the SAS OnDemand for Professionals server, I know that the BOOKDATA folder has Prep Guide datasets and flat files. (Although I do not see data.txt in the folder when I look at my OnDemand for Professionals account.) But, it was my understanding that your professor would upload the data you needed to your class image on the server when you used SAS OnDemand for Academics.
For questions about what data is on your SAS OnDemand for Academics server account and how to point to that data is something that you should ask of your professor or work with SAS Tech Support by sending mail to email@example.com. I don't have an OnDemand for Academics account and I can't look at what is loaded on your account. But, I am posting a picture of what my SAS OnDemand for Professionals server list looks like and it shows the sas_cert_prep_guide folder with SAS datasets and other files.
The forum is a wonderful resource and as you found out with your FILENAME statement, when you are asking syntax and coding questions, you will find a lot of help. Because your particular usage scenario is a special use case, you might want to work with Tech Support (as suggested in the Commonly Asked Questions) on data issues, such as how to find data or how to point to data. Specifically, with relation to the Prep Guide, you might look for some other postings like this one: https://communities.sas.com/message/197492#197492. Reading and writing Excel files will be an "issue" -- Microsoft doesn't install on Unix servers. So in the current OnDemand configuration, you cannot read or write Excel files. Many other students have this same "issue" -- they too have to study syntax that they can't run (primarily because Excel doesn't install on the mainframe, either).
Overall, I think that if you focus more on the code, you will learn much about SAS coding and how powerful the DATA step is and how flexible SAS is when it comes to reading data and converting "raw" data into SAS datasets for analysis.