Skip to content

Instantly share code, notes, and snippets.

@joosti
Created January 26, 2015 23:34
Show Gist options
  • Save joosti/a7d8688246012ce1afb0 to your computer and use it in GitHub Desktop.
Save joosti/a7d8688246012ce1afb0 to your computer and use it in GitHub Desktop.
SAS Macro variables in remote submit (rsubmit) using SYSLPUT
/* Making macro variables available on remote server with syslput */
/* login to remote server */
%let wrds = wrds.wharton.upenn.edu 4016;options comamid = TCP remote=WRDS;
signon username=_prompt_;
/* this macro retrieves Compustat Funda variables from year1 to year2 */
%macro getFunda(dsout=, year1=2010, year2=2013, vars=);
/* syslput pushes macro variables to the remote connection */
%syslput dsout = &dsout;
%syslput year1 = &year1;
%syslput year2 = &year2;
%syslput vars = &vars;
rsubmit;
%put Year1 value: &year1 - year2 value: &year2;
%put Collect variables &vars and create &dsout;
data a_funda (keep = gvkey fyear &vars);
set comp.funda;
if &year1 <= fyear <= year2;
if indfmt='INDL' and datafmt='STD' and popsrc='D' and consol='C' ;
run;
proc download data=a_funda out=&dsout;
endrsubmit;
%mend;
/* invoke */
%getFunda(dsout=a_funda1, vars=at sale ceq);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment