BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Abdu
Calcite | Level 5

Hi All,

I wanted to define an array with dynamic Dimension according the real data.  I create a macro variable &MAXCYC, and I checked, it had 25 in my program.  Now I want to define an array of &MAXCYC dimension with name as CYCLE_1-CYCLE_&MAXCYC.  I used the following format, but I got error message:

ARRAY CYC_N{&MAXCYC} CYCLE_1-CYCLE_&MAXCYC;

MESSAGE:

NOTE: Line generated by the macro variable "MAXCYC".

1     CYCLE       5

                  -

                  22

                  200

ERROR: Missing numeric suffix on a numbered variable list (CYCLE1-CYCLE).

ERROR: Too few variables defined for the dimension(s) specified for the array CYC_N.

ERROR 22-322: Syntax error, expecting one of the following: a name, (, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.

ERROR 200-322: The symbol is not recognized and will be ignored.

How do I solve this issue?

Thanks,

Abdu.

1 ACCEPTED SOLUTION

Accepted Solutions
dkb
Quartz | Level 8 dkb
Quartz | Level 8

Left-justify the macro variable when you create it - perhaps you used something like -

CALL SYMPUT('MAXCYC', PUT(n, 8.));

Use this instead:

CALL SYMPUT('MAXCYC', LEFT(PUT(n, 8.)));

Alternatively, left-justify when you invoke it:

ARRAY CYC_N{&MAXCYC} CYCLE_1-CYCLE_%LEFT(&MAXCYC);

View solution in original post

2 REPLIES 2
dkb
Quartz | Level 8 dkb
Quartz | Level 8

Left-justify the macro variable when you create it - perhaps you used something like -

CALL SYMPUT('MAXCYC', PUT(n, 8.));

Use this instead:

CALL SYMPUT('MAXCYC', LEFT(PUT(n, 8.)));

Alternatively, left-justify when you invoke it:

ARRAY CYC_N{&MAXCYC} CYCLE_1-CYCLE_%LEFT(&MAXCYC);

Reeza
Super User

Call symputX instead of call symput

or trim the variable in your SQL step:

proc sql;

select trim(count(*)) into :max_count

from blah;

quit;

You can also consider the wildcard operators if you only have the variables in cycle_1 - cycle_5 starting with cycle_ in the dataset. If you have other variables such as cycle_max then this won't work.

array cyc_n(*) cycle_:;

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
  • 2 replies
  • 2323 views
  • 3 likes
  • 3 in conversation