'selif' does not work for strings

I am using Gauss 16.0.3 build 4205.  My problem is that the Gauss built-in function 'selif' does not read in strings (only string arrays). Some of my simulations stop because the first argument of the input (which is a string array at the beginning of the simulation) becomes a string during the simulation process. Below I provide an example. How can this issue be solved?

Example:

let string var = a b c;
sol = selif(var[1],1);

 

 

1 Answer



0



Thank you for reporting this issue. It has been resolved, but not yet released in GAUSS version 17 for both selif and delif.

In the mean time, you can use indexcat and indexing. For example, if you know an element will always be selected:

str = "Apple" $| "Banana" $| "Canteloupe";

//Select last row only
mask = { 0, 0, 1 };
str = str[indexcat(mask, 1)];
print "str = " str;


print "-----------------------";
//Select only remaining element
mask = 1;
str = str[indexcat(mask, 1)];
print "str = " str;

In the event that no element is selected, indexcat will return a scalar error code which you can check for with either scalmiss or ismiss. For example:

str = "Apple" $| "Banana" $| "Canteloupe";

//Do not select any rows
mask = 0;
str = str[indexcat(mask, 1)];
if scalmiss(str);
   //code to handle case where nothing was selected
endif;

aptech

1,773

Your Answer

1 Answer

0

Thank you for reporting this issue. It has been resolved, but not yet released in GAUSS version 17 for both selif and delif.

In the mean time, you can use indexcat and indexing. For example, if you know an element will always be selected:

str = "Apple" $| "Banana" $| "Canteloupe";

//Select last row only
mask = { 0, 0, 1 };
str = str[indexcat(mask, 1)];
print "str = " str;


print "-----------------------";
//Select only remaining element
mask = 1;
str = str[indexcat(mask, 1)];
print "str = " str;

In the event that no element is selected, indexcat will return a scalar error code which you can check for with either scalmiss or ismiss. For example:

str = "Apple" $| "Banana" $| "Canteloupe";

//Do not select any rows
mask = 0;
str = str[indexcat(mask, 1)];
if scalmiss(str);
   //code to handle case where nothing was selected
endif;

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