Tiny URL Macro

From sasCommunity
Jump to: navigation, search

The following macro creates a tiny url from a long url.

Macro

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 ;

Author

Alan Churchill