number to string

In my program, I want to create variables in order, say X1, X2, X3...X8

I have been trying this:

for years (1,8,1);
    proc stats(name,curr_stats1) ;
        local curr_stats, mean_curr_stats ;
        curr_stats = varget(name$+"_1") ;
        mean_curr_stats = sumc(curr_stats) / sumc(curr_stats.>0) ;
        print mean_curr_stats;

stats("simul_wages_male",simul_wages_male_1) ;

But as you can see I am not able to do something like

curr_stats = varget(name $+ "_" $+ years)

because years is a numeric scalar, so my question is, how can I convert a scalar into a string to automatize the process?

3 Answers


If you have GAUSS 14 or newer, you can use the function ntos. Here is a basic example:

for i(1, 5, 1);
   print "my_variable_"$+ntos(i);


I have Gauss 13 🙁


Well then I think the simplest replacement for ntos would be this:

for i(1, 5, 1);
   print "my_variable_"$+cvtos(ftocv(i, 0, 0));

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