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

Hi, i have a problem with the dimension definiton of an array. My code works good in SAS Guide, but in the bash does't works. 

The macro variables nvars and obs are definited as:

 

data _null_;

set sashelp.vtable (where= (memname='ABT_DUMMY'));

 call symput('nvars', nvar-1);

 call symput('obs', nobs);

 run;

 

I wish to put the macros in array dimension:

 

data bt_lambda (keep= var dot);

        array xx[&nvars.] x_1-x_&nvars.;

        array xd[&obs., &nvars.] _temporary_;

run;

But return the errors:

train.png

 

 

The code works if i defined the macros as:

%let nvars=23;

%let obs=84000;

But i need the dynamical dimension. Someone can tell me a solution?

 

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

The log shows that "nvars" is -1 not 23. Using call symputx is recommended, so that blanks are automatically stripped from the macro-variable.

View solution in original post

4 REPLIES 4
andreas_lds
Jade | Level 19

The log shows that "nvars" is -1 not 23. Using call symputx is recommended, so that blanks are automatically stripped from the macro-variable.

rodbriv
Calcite | Level 5
Yea, i got a problem with teh data step of definition.
With a proc sql
proc sql; select cats(nvar) into :nvars from sashelp.vtable where memname=’ABT_DUMMY’;
proc sql; select cats(nobs) into :obs from sashelp.vtable where memname=’ABT_DUMMY’;
Works well, the problem was the symput and the blanks. Thanks.
Kurt_Bremser
Super User

First of all, use CALL SYMPUTX instead of CALL SYMPUT. SYMPUTX strips leading and trailing blanks.

It looks as if your dataset does not contain any variables (resulting in nvars being -1, which is an invalid dimension for the array).

rodbriv
Calcite | Level 5
Yea, i got a problem with teh data step of definition.
With a proc sql
proc sql; select cats(nvar) into :nvars from sashelp.vtable where memname=’ABT_DUMMY’;
proc sql; select cats(nobs) into :obs from sashelp.vtable where memname=’ABT_DUMMY’;
Works well, the problem was the symput and the blanks. Thanks.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1268 views
  • 0 likes
  • 3 in conversation