DATA Step, Macro, Functions and more

problem with reading external file

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

problem with reading external file

I have bought Enterprise Guide 6.1 + license to learn basic SAS to study, and try to follow small pieces of code there.

For this code:

filename ch5_154 'C:\SAS_OnDemand_for_Professionals\Raw_files\ch5_154.txt';

data exercise;

infile ch5_154;

input ID $ 1-4 Age $ 6-7 ActLevel $ 9-12 Gender $ 14;

run;

I got this message in a log:

ERROR: Physical file does not exist, /sso/biconfig/930/Lev1/SASApp/C:\SAS_OnDemand_for_Professionals\Raw_files\ch5_154.txt.

Here is the file  'C:\SAS_OnDemand_for_Professionals\Raw_files\ch5_154.txt' content:

2810 61 MOD F

2804 28 HIGH F

2807 42 LOW M

2816 26 HIGH M

2833 32 MOD F

2823 29 HIGH M

Log shows this extra piece in file address added automatically:  /sso/biconfig/930/Lev1/SASApp/

I did not see anything in Options to fix that, and I could not locate related  properties to remove this extra.

Can anyone help?

Vladimir


Accepted Solutions
Solution
‎03-16-2014 01:49 PM
SAS Super FREQ
Posts: 8,868

Re: problem with reading external file

Hi:

  When you use the SAS OnDemand for Professionals license to access SAS on the "cloud" server, you CANNOT read from your local C: drive. That "extra" information appended to the FILENAME is the UNIX directory on the OnDemand server that is your "default" location. Anytime SAS OnDemand for Professionals reads a data file, it looks in the server default location, which is /sso/biconfig/930/Lev1/SASApp -- note how the name of the server in the screen shot is SASApp.

  

  Depending on which book you are using or which course you are taking, the FILENAME statement  or INFILE statement would be different. I do not recognize the name

filename ch5_154 'C:\SAS_OnDemand_for_Professionals\Raw_files\ch5_154.txt';

 

as belonging to one of the books that is currently loaded on the server, which could be problematic for you if your data is *NOT* loaded on the OnDemand server. What book are you using? As you can see in the second screen shot, there are a limited number of books loaded on the server.

 

But, I wanted to show that data could be read from the server, given the right location. So, instead, my code below reads the CITYDATA.DAT file that is in the Certification Prep Guide directory, as shown in the screen shot:

data work.citypop;
  length city $25;
  infile '~/bookdata/sas_cert_prep_guides/citydata.dat';
  input city $ pop70 pop80;
run;

   

proc print data=work.citypop;
run;

     

OR

filename cpop '~/bookdata/sas_cert_prep_guides/citydata.dat';

  

data work.citypop2;
  length city $25;
  infile cpop;
  input city $ pop70 pop80;
run;

      

proc print data=work.citypop2;
run;

  

  According to the guidelines for SAS OnDemand for Professionals, you CANNOT read your personal C:\ drive files. See these links:

SAS OnDemand for Professionals (sentence that starts: Note: SAS OnDemand for Professionals: Enterprise Guide does not have the capability for uploading of personal data.)

or

SAS OnDemand for Professionals (FAQ about the data)

  

  The only courses and books that work with the SAS OnDemand for Professionals server are the ones listed here (SAS OnDemand for Professionals [Learning Options tab]). The only exception to this is if you are using a similar license called SAS OnDemand for Academics, where your professor can load data for his/her course onto the server. If this is your usage scenario, then your instructor should give you the correct *server* location (not C: drive location) for the uploaded data.

  

cynthia


list_of_bookdata_folder.pngINFILE_SODP.png

View solution in original post


All Replies
Super User
Super User
Posts: 7,074

Re: problem with reading external file

This is a common mistake. EG is a windows product running on your PC that serves as a front end to SAS. SAS itself is running somewhere else.  So it cannot see the files on your windows machine.

Why not just convert to using CARDS (or as they now call it DATALINES) statement and paste the contents of your file into your program?

Solution
‎03-16-2014 01:49 PM
SAS Super FREQ
Posts: 8,868

Re: problem with reading external file

Hi:

  When you use the SAS OnDemand for Professionals license to access SAS on the "cloud" server, you CANNOT read from your local C: drive. That "extra" information appended to the FILENAME is the UNIX directory on the OnDemand server that is your "default" location. Anytime SAS OnDemand for Professionals reads a data file, it looks in the server default location, which is /sso/biconfig/930/Lev1/SASApp -- note how the name of the server in the screen shot is SASApp.

  

  Depending on which book you are using or which course you are taking, the FILENAME statement  or INFILE statement would be different. I do not recognize the name

filename ch5_154 'C:\SAS_OnDemand_for_Professionals\Raw_files\ch5_154.txt';

 

as belonging to one of the books that is currently loaded on the server, which could be problematic for you if your data is *NOT* loaded on the OnDemand server. What book are you using? As you can see in the second screen shot, there are a limited number of books loaded on the server.

 

But, I wanted to show that data could be read from the server, given the right location. So, instead, my code below reads the CITYDATA.DAT file that is in the Certification Prep Guide directory, as shown in the screen shot:

data work.citypop;
  length city $25;
  infile '~/bookdata/sas_cert_prep_guides/citydata.dat';
  input city $ pop70 pop80;
run;

   

proc print data=work.citypop;
run;

     

OR

filename cpop '~/bookdata/sas_cert_prep_guides/citydata.dat';

  

data work.citypop2;
  length city $25;
  infile cpop;
  input city $ pop70 pop80;
run;

      

proc print data=work.citypop2;
run;

  

  According to the guidelines for SAS OnDemand for Professionals, you CANNOT read your personal C:\ drive files. See these links:

SAS OnDemand for Professionals (sentence that starts: Note: SAS OnDemand for Professionals: Enterprise Guide does not have the capability for uploading of personal data.)

or

SAS OnDemand for Professionals (FAQ about the data)

  

  The only courses and books that work with the SAS OnDemand for Professionals server are the ones listed here (SAS OnDemand for Professionals [Learning Options tab]). The only exception to this is if you are using a similar license called SAS OnDemand for Academics, where your professor can load data for his/her course onto the server. If this is your usage scenario, then your instructor should give you the correct *server* location (not C: drive location) for the uploaded data.

  

cynthia


list_of_bookdata_folder.pngINFILE_SODP.png
🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 582 views
  • 3 likes
  • 3 in conversation