Tuesday, December 27, 2011

SAS Macro to Make Tiny URLs

Someone on SAS-L wanted a piece of SAS code to convert a long url to a short one. Well, here you go:


filename in "x:\temp\in";
filename out "x:\temp\out.txt";

%macro MakeTiny(longUrl=);
 data _null_;
    file in lrecl=1028;
    put "url=&longUrl" ;
    run;

    proc http in=in out=out url="http://tinyurl.com/api-create.php"
      method="post"
      ct="application/x-www-form-urlencoded";
 run;

 data _null_ ;
    infile out;
    input tinyUrl :$1024. ;
    call symput('tinyUrl',tinyUrl);
    %global tinyUrl ;
    run;

%mend makeTiny;

%MakeTiny(longUrl=www.savian.net);

%put &tinyUrl ;

No comments:

CTRL+Z does not generate EOF in Windows 10

In Windows 10, when I was trying to generate an EOF for a Java program, the CTRL+Z did not work. After doing some research (and help from f...