Problmes with SAS University Edition and e-learning

Reply
New Contributor
Posts: 2

Problmes with SAS University Edition and e-learning

Hi,

I just downloaded SAS University Edition and I'm learning how to use it. I'm taking SAS Programming 1: Essentials and I'm having problems with it.

In one exercise I have to run this code:

data work.country2;

   length Country_Code $ 2 Country_Name $ 48;

  infile "&path/country.dat" dlm='!';

   input Country_Code $ Country_Name $;

run;

proc print data=work.country2;

run;

When I run it SAS shows me this log:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

42 ;

43 data work.country2;

44 length Country_Code $ 2 Country_Name $ 48;

45 infile "&path/country.dat" dlm='!';

46 input Country_Code $ Country_Name $;

47 run;

ERROR: Physical file does not exist, /folders/myfolders/ecprg193/country.dat.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.COUNTRY2 may be incomplete. When this step was stopped there were 0 observations and 2 variables.

WARNING: Data set WORK.COUNTRY2 was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

  real time 0.00 seconds

  cpu time 0.00 seconds

  

48 

49 proc print data=work.country2;

50 run;

NOTE: No observations in data set WORK.COUNTRY2.

NOTE: PROCEDURE PRINT used (Total process time):

  real time 0.00 seconds

  cpu time 0.00 seconds

In "My Folders" all files have the extension .sas7bdat. Well, I thought that the problem was the extension in my code so I changed it and ran again. But it didn't work! SAS start running and don't stop...

Someone knows whats is happening?

Super User
Posts: 17,840

Re: Problmes with SAS University Edition and e-learning

1. Did you run the step where you first create the files for the course?

2. There was an issue with the software hanging. Do you have the latest version of the software?

SAS Super FREQ
Posts: 8,743

Re: Problmes with SAS University Edition and e-learning

Hi:
Your code or one of your files should have a reference to &PATH. Possibly in a LIBNAME.SAS or a SETUP.SAS program. The bottom line is that your program expects to find the data file COUNTRY.DAT in a subfolder called 'ecprg193'  -- because that's where your &PATH is pointed. Look at the attached screen shot. I do have COUNTRY.DAT in my Windows Explorer folder structure as shown in the screen shot:

c:\SASUniversityEdition\myfolders\ecprg193
         

So, my  &PATH macro variable to hold the path location was set to the shared folder location in a UNIX path style:  /folders/myfolders/ecprg193

And, my program shows these 2 statements --

%let path=/folders/myfolders/ecprg193;

infile "&path/country.dat" dlm='!';

Then, because I had the location that was the shared folder location as defined, my program was successful, as shown in the screen shot of the SAS log.
        

If I did NOT use &PATH, then my INFILE statement would have been:

  infile "/folders/myfolders/ecprg193/country.dat" dlm='!';
        

  The only reason for using the &PATH macro variable is so the location does NOT need to be hard-coded in every program. Every time I start SAS Studio, if I run a program that gives &PATH a value, then if I move my data around to a different shared folder, I only have to change 1 statement instead of every place I hard-coded the location.

  But, back to your INFILE statement, if you can see the COUNTRY.DAT file in MYFOLDERS (and NOT in a subdirectory), then you need to either:

1) change your %LET statement to have the correct UNIX path (and leave the program code unchanged)

%let path=/folders/myfolders;

or

2) hard-code the infile statement as shown below:

   infile "/folders/myfolders/country.dat" dlm='!';
       

Of course, if you have the data in a different subdirectory or folder, then you must have the right location or your INFILE statement won't work.
     

  Here's another way of considering the whole location/folder challenge --you have a box (1), in a box (2), in a box (3).
      

  The smallest box (1) is the SAS University Edition application. It is a Unix box and you don't really do anything with that application except reach into it with SAS Studio. But, the SAS University Edition is a Unix/Linux application. So it expects a certain folder structure, based on what has been defined in your Virtual Machine software (which is box #2 -- either Virtual Box or VMware Player). SAS University Edition (box #1) knows how to go to box #2 (Virtual Box or VMware Player) to find where to look for files on box #3 (your computer).
    

  If the location that you specify is a C: drive location, and you try to make SAS University Edition go directly to a C: drive location, then your INFILE or LIBNAME statement won't work. SAS University Edition only "speaks" Unix locations. So you have to understand how the folders you see inside SAS Studio correspond to the physical folders on your computer. If you look at my screen shot, you will see how my folder structure on my C: drive directly maps to the UNIX name that is used for COUNTRY.DAT. On the other hand, your SAS Log is telling you that it looked for the files in your shared folder location in a subdirectory called ecprg193 and didn't find them there.
     

  Once you fix your INFILE statement to have the correct location (by correctly "translating" your computer location to a UNIX location), then the program should work as shown in my log.
      

cynthia


how_to_infile_country_data.pngsuccessful_log_read_country.png
New Contributor
Posts: 2

Re: Problmes with SAS University Edition and e-learning

Thank you all!

I just run again the step where we first create the files for the course and now it's working.

Thank you too much Cynthia@sas. I really appreciated your answer =)

Super User
Posts: 17,840

Re: Problmes with SAS University Edition and e-learning

Then one of two possibilities - the files were not created properly or the macro variable path was not defined in this session.

Ask a Question
Discussion stats
  • 4 replies
  • 3973 views
  • 7 likes
  • 3 in conversation