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;
    endp;
endfor;

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



0



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);
endfor;

aptech

1,773


0



I have Gauss 13 🙁



0



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));
endfor;

aptech

1,773

Your Answer

3 Answers

0

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);
endfor;

0

I have Gauss 13 🙁

0

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));
endfor;


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.