How to generate scalar names in a loop

I am still quite a beginner with GAUSS... I know the varput function allows me to create matrices with a name based on my loop. Is it also possible to create scalars in such a way so that I can automate it in the loop? If not, what would be the most elegant alternative solution?

Thank you!

position = 5;                
if countries eq 2;
    for k(1,6,1);
        name = strput(kvector[1,k], "i_", 3);
        y = varput(position, name); 
        position = position+1;
    endfor;                                     
endif;

2 Answers



0



Most likely you do not want to create all of those scalar values. Depending on how you want to use the data, you would probably be better off with either a structure to hold the data for each country or a vector to contain these scalar values.

aptech

1,773


0



The scalar values are supposed to be column indicators that are called upon in a later part of the code. Since I didn't write the majority of the code myself the scalar names are already distributed around the code already. I tried using a element 1,1 of the varput matrix (that has the name I want for the scalar) as a column indicator, but this did not work due to the multiple closed square brackets.

ftd

2

Your Answer

2 Answers

0

Most likely you do not want to create all of those scalar values. Depending on how you want to use the data, you would probably be better off with either a structure to hold the data for each country or a vector to contain these scalar values.

0

The scalar values are supposed to be column indicators that are called upon in a later part of the code. Since I didn't write the majority of the code myself the scalar names are already distributed around the code already. I tried using a element 1,1 of the varput matrix (that has the name I want for the scalar) as a column indicator, but this did not work due to the multiple closed square brackets.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy