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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 493 views
  • 0 likes
  • 3 in conversation