Follow up on uniqindxsa

Thank you for your answer. I have tried this but it didn't work. I think the reason for this is that the text was originally entered in the matrix not as strings e.g. not

X = { "Marl" "Winf"}

but

X = {Marl Winf}

 

1 Answer



0



If the data is 'character' data i.e. characters packed inside matrix elements, then you need to use the function uniqIndx. The last input to uniqIndx is a flag to tell the function whether your input is numeric or character data. Here is an example:

//Create matrix of character data
vnames = {    gdp    M2,
           t-bill   gdp,
          exports   gdp };

//Transform data to a vector
vnames = vecr(vnames);

//Find index of unique elements
is_numeric = 0;
u_idx = uniqIndx(vnames, is_numeric);

print "unique variable names include: " $vnames[u_idx];

aptech

1,773

Your Answer

1 Answer

0

If the data is 'character' data i.e. characters packed inside matrix elements, then you need to use the function uniqIndx. The last input to uniqIndx is a flag to tell the function whether your input is numeric or character data. Here is an example:

//Create matrix of character data
vnames = {    gdp    M2,
           t-bill   gdp,
          exports   gdp };

//Transform data to a vector
vnames = vecr(vnames);

//Find index of unique elements
is_numeric = 0;
u_idx = uniqIndx(vnames, is_numeric);

print "unique variable names include: " $vnames[u_idx];

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.