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.
(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;
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:
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:
Thank you so much!
I resolved the issue using your advice.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.