DATA Step, Macro, Functions and more

Export file to PC after downloading data and taking data setps from WRDS wireless access

Accepted Solution Solved
Reply
Contributor
Posts: 26
Accepted Solution

Export file to PC after downloading data and taking data setps from WRDS wireless access

Hi,

 

I ran the program(PROGRAM A) that download return data from WRDS wireless access and want to export the final datafile ('ret1214) to my PC. However, I see the following error message. Any advice will be highly appreciated.

 

104
105 libname new 'C:\Users\hakjoon\Documents\Business strategy\Data
105! analyses';
NOTE: Library NEW does not exist.
106 data new.returns1214; set ret1214; run;
ERROR: Library NEW does not exist.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.01 seconds
 
NOTE: Remote submit to WRDS complete.

 

 

 

 

(PROGRAM A)

options ls = 104;

options ls=72 ps=max nocenter nonumber nodate fullstimer ;

%let wrds = wrds-cloud.wharton.upenn.edu 4016;

options comamid=TCP remote=WRDS;

signon username=_prompt_;

rsubmit;

options source ls=72 ps=max;

option obs=max;

libname compx '/wrds/comp/sasdata/nam' ;

libname crsp '/wrds/crsp/sasdata/a_stock' ;

run;

* Date range-- applied to FYEAR ( Fiscal Year);

%let fyear1= 2012;

%let fyear2= 2014;

* Selected data items (GVKEY, DATADATE, FYEAR and FYR are automatically included);

%let vars= cusip ;

%let out_ds= work.compx2;

%let n_month_after=3;

 

data &out_ds;

set compx.funda(keep= gvkey datadate fyear fyr &vars indfmt datafmt popsrc consol);

where fyear between &fyear1 and &fyear2;

if indfmt='INDL' and datafmt='STD' and popsrc='D' and consol='C';

drop indfmt datafmt popsrc consol; * Only used for the screening;

run;

proc sort; by gvkey fyear; run;

title ' get CUSIP FYE FME and Calendar year';

data temp;

set compx2;

cusip = substr(cusip, 1, 8);

ID=_N_;

calyear=fyear;

fme = fyr;

fye = fyear;

if 1<=Fyr<=5 then calyear=Fyear+1;

proc print data=temp(obs=10); run;

data temp2;

set temp;

format begdate enddate date9.;

m=fme+&n_month_after+1;

y=calyear-1;

if fme+&n_month_after+1>12 then do

m=mod(fme+&n_month_after+1,12);

y=calyear;

end;

begdate=mdy(m,1,y);

enddate=intnx('month',begdate,12)-1;

proc print data=temp2(obs=10); run;

title ' get data from dsfnames';

data temp3;

set crsp.stocknames;

keep cusip permno st_date end_date;

proc sort nodupkey; by cusip permno st_date end_date;run;

proc print data=temp3(obs=4); run;

 

title ' merge temp4';

proc sort data=temp2;by cusip;run;

proc sort data=temp3;by cusip;run;

data temp4;

merge temp2(in=a) temp3(in=b);

by cusip;

if a and b;

drop y m;

proc print data=temp4(obs=5); run;

title 'get ret from crsp.dsf ';

proc sql;

create table dsf

as select x.ID, x.begdate,x.enddate, s.*

from temp4 as x

left join crsp.dsf (keep= date permno ret) as s

on s.permno = x.permno and (x.begdate <= s.date <= x.enddate);

quit;

proc print data=dsf(obs=3); run;

 

title ' get compound return ';

proc sql;

create table compound as

select ID,permno,

exp(sum(log(1+ret ))) - 1 as compnd, min(ret) as minret, max(ret) as maxret,

n(ret) as n, nmiss(ret) as n_miss, sum(ret=.P) as n_dot_p

from dsf(keep=ID permno date ret begdate enddate)

where begdate<=date<=enddate

group by ID;

quit;

run;

proc print data=compound(obs=4); run;

proc sort data=compound nodupkey;

by ID PERMNO compnd minret maxret n n_miss n_dot_p;

run;

proc print data=compound(obs=10); run;

proc sort data=temp4;by ID;

proc sort data=compound;by ID;

data ret1214;

merge temp4(in=a) compound;

by ID;

format begdate enddate yymmddn8.;

keep gvkey CUSIP Fyear Fyr begdate enddate PERMNO compnd minret maxret n;

run;

proc means data=ret1214;run;

libname new 'C:\Users\hakjoon\Documents\Business strategy\Data analyses';

data new.returns1214; set ret1214; run;


Accepted Solutions
Solution
‎12-11-2015 04:44 PM
Trusted Advisor
Posts: 1,117

Re: Export file to PC after downloading data and taking data setps from WRDS wireless access

[ Edited ]

I guess, "C:\..." refers to the local C drive of your PC. But you submit the LIBNAME statement to the remote machine, because it is contained in the RSUBMIT-ENDRSUBMIT block (the end of which is not visible in your code).

 

Two options would be:

  • If you can access any local drive of your PC from the remote computer, you can just replace "C:\..." in the LIBNAME statement by the appropriate UNC path (e.g. "\\YourPCname\SharedFolder\...") and then let the remote machine push the file to your local PC.
  • If you can access the remote directory from your local PC, you can use a LIBNAME statement like libname myremlib remote '/enter/the/remote/path/here' server=...; and then let your local PC pull the file from the remote location. This LIBNAME statement must be outside the RSUBMIT-ENDRSUBMIT block.

View solution in original post


All Replies
Solution
‎12-11-2015 04:44 PM
Trusted Advisor
Posts: 1,117

Re: Export file to PC after downloading data and taking data setps from WRDS wireless access

[ Edited ]

I guess, "C:\..." refers to the local C drive of your PC. But you submit the LIBNAME statement to the remote machine, because it is contained in the RSUBMIT-ENDRSUBMIT block (the end of which is not visible in your code).

 

Two options would be:

  • If you can access any local drive of your PC from the remote computer, you can just replace "C:\..." in the LIBNAME statement by the appropriate UNC path (e.g. "\\YourPCname\SharedFolder\...") and then let the remote machine push the file to your local PC.
  • If you can access the remote directory from your local PC, you can use a LIBNAME statement like libname myremlib remote '/enter/the/remote/path/here' server=...; and then let your local PC pull the file from the remote location. This LIBNAME statement must be outside the RSUBMIT-ENDRSUBMIT block.
Contributor
Posts: 26

Re: Export file to PC after downloading data and taking data setps from WRDS wireless access

Posted in reply to FreelanceReinhard

Thank you so much!

I resolved the issue using your advice.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 354 views
  • 0 likes
  • 2 in conversation