Monday, March 12, 2012

use SAS to read data from website: use filename url

a sample sas code:



filename testdata url "http://dl.dropbox.com/u/10684315/sas_pub/sas_read_webdata.csv";

data test;
  infile testdata dsd firstobs=2;
  length CANONICAL_KEYWORD $400.;
  input keyword_id CANONICAL_KEYWORD $ node_id rank;
run;

data test;
  set test;
  canonical_keyword=translate(canonical_keyword,' ','"');
  canonical_keyword=trim(left(canonical_keyword));
run;

proc contents data=test;
run;

proc print data=test width=min;
run;


An example code from SAS help:



filename foo url 
    'http://support.sas.com/techsup/service_intro.html';
       
data _null_;
   infile foo length=len;
   input record $varying200. len;
   put record $varying200. len;
   if _n_=15 then stop;
run; 

No comments:

Post a Comment