BookmarkSubscribeRSS Feed
sk2202
Calcite | Level 5

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

3 REPLIES 3
Reeza
Super User

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. 

sk2202
Calcite | Level 5

%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

Reeza
Super User

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.

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 910 views
  • 0 likes
  • 2 in conversation