Search code examples
csvsas

Error in downloading data directly from internet


I want to download some data in CSV format from internet and used below code

proc import datafile = 'https://raw.githubusercontent.com/sam16tyagi/Machine-Learning-techniques-in-python/master/logistic%20regression%20dataset-Social_Network_Ads.csv' out = Dat dbms = CSV;
run;

However above line generates error like below

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         proc import datafile =
 69       ! 'https://raw.githubusercontent.com/sam16tyagi/Machine-Learning-techniques-in-python/master/logistic%20regression%20datase
 69       ! t-Social_Network_Ads.csv' out = Dat1 dbms = CSV;
 70         run;
 
 NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to 
 WORK.PARMS.PARMS.SLIST.
 ERROR: Physical file does not exist, 
 /pbr/biconfig/940/Lev1/SASApp/https://raw.githubusercontent.com/sam16tyagi/Machine-Learning-techniques-in-python/master/logistic%20r
 egression%20dataset-Social_Network_Ads.csv. 
 ERROR: Import unsuccessful.  See SAS Log for details.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.02 seconds
       user cpu time       0.01 seconds
       system cpu time     0.01 seconds
       memory              8223.21k
       OS Memory           29208.00k
       Timestamp           13/07/2024 10:42:38 AM
       Step Count                        48  Switch Count  5
       Page Faults                       0
       Page Reclaims                     1172
       Page Swaps                        0
       Voluntary Context Switches        27
       Involuntary Context Switches      1
       Block Input Operations            0
       Block Output Operations           40
       
 71         
 72         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 82         



 

Could you please help to understand why it is failing what will be the correct code?


Solution

  • PROC IMPORT is looking for a local file by default, as you can tell from the error (it's searching inside /pbr/biconfig). You can define a URL filename instead:

    filename github url "https://raw.githubusercontent.com/sam16tyagi/Machine-Learning-techniques-in-python/master/logistic%20regression%20dataset-Social_Network_Ads.csv";
    
    proc import datafile=github dbms=csv out=dat;
    quit;