hey,
I got some problems with a given code (proc timeseries) which I should transfer into a macro:
%macro create_timeseries;
proc timeseries
data=&library..&varticker._tick
out=q&varticker._&interval.min;
id time interval=MINUTE5.
accumulate=total
setmiss=0;
var quantity;
run;
proc timeseries
data=&library..&varticker._tick
out=p&varticker._&interval.min;
id time interval=MINUTE5. accumulate=LAST;
var price;
run;
proc sql;
create table &library..&varticker._&interval.min as select
a.* ,b. *
from q&varticker._&interval.min a full join p&varticker._&interval.min
b
on a.time = b.time;
quit;
run;
%mend create_timeseries;
Errors:
WARNING: Apparent symbolic reference LIBRARY not resolved.
NOTE: Line generated by the invoked macro "CREATE_TIMESERIES".
1 &library..&varticker._tick
-
22
200
1 ! out=q&varticker._&interval.min; id time interval=MINUTE5.
1 ! accumulate=total setmiss=0; var quantity; run; proc timeseries
WARNING: Apparent symbolic reference INTERVAL not resolved.
NOTE 138-205: Line generated by the macro variable "INTERVAL".
1 qE_STANL_BTSE_&
-
22
ERROR 22-322: Expecting ein Name.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, BYVECTORPLOTS, COUNTPLOTS,
CROSSPLOTS, DATA, LABEL, MAXERROR, MAXVARLENGTH, OUT, OUTCORR, OUTCROSSCORR,
OUTDECOMP, OUTFREQ, OUTPROCINFO, OUTSEASON, OUTSPECTRA, OUTSSA, OUTSUM, OUTTREND,
OUTXMLINFO, OUTXMLTREE, PLOTS, PRINT, PRINTDETAILS, SEASONALITY, SORTNAMES,
THUMBPLOTS, VECTORPLOTS, XML.
NOTE: Line generated by the macro variable "INTERVAL".
1 qE_STANL_BTSE_&
-
200
ERROR 200-322: The symbol is not recognized and will be ignored.
WARNING: Apparent symbolic reference INTERVAL not resolved.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.QE_STANL_BTSE_ may be incomplete. When this step was stopped there
were 0 observations and 0 variables.
WARNING: Datei WORK.QE_STANL_BTSE_ wurde nicht ersetzt. Grund: da dieser Schritt angehalten wurde.
NOTE: PROZEDUR TIMESERIES used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Thank you in advance. Best regards,
sk2202
Your macro variables aren't assigned for starters as indicated by errors.
Fix that and then see what else is wrong. L
I would recommend you pass parameters to your macro as well.
%macro create_timeseries(library,varticker);
data = &library..&varticker._tick_t;
set = &library..&varticker._tick;
run;
proc timeseries
data=&library..&varticker._tick_t
out=q&varticker._&interval.min;
id time interval=MINUTE5.
accumulate=total
setmiss=0;
var quantity;
run;
proc timeseries
data=&library..&varticker._tick_t
out=p&varticker._&interval.min;
id time interval=MINUTE5. accumulate=LAST;
var price;
run;
proc sql;
create table &library..&varticker._&interval.min as select
a.* ,b. *
from q&varticker._&interval.min a full join p&varticker._&interval.min
b
on a.time = b.time;
quit;
run;
%mend create_timeseries;
%create_timeseries(time,price,quantity);
Do you mean like this? Best regards
Sort of.
Your macro definition
%macro createtimeseries(library, varticker);
Your macro call:
%createtimeseries(time, price, quantity);
Note that you have more items in your macro call than definition. This wil generate an error. If you need a third paramete it must be declared.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.