Variable Length - SAS

0

I am making an if in SAS to declare the value that a variable will receive depending on the condition, however when I say that the variable will receive a string of size up to 3 it returns correctly but indicating that it will receive a string of size 4 or higher, it returns only the first 3 characters!

Example Code:

    IF   RECEITA 1000000 AND  RECEITA_ LE 10000000 THEN
    P = '>1'||'M';

ELSE IF  RECEITA 10000000 THEN
    P = '>10'||'M';

In the first case it returns correctly, ie> 1M. In the second case it returns > 10, missing the character 'M'.

I have already tried functions such as cat and substr, and even just declare, for example, P="> 10M", but the same problem happens.

    
asked by anonymous 29.08.2018 / 20:27

1 answer

0

You should note that P has 4 characters Strings, because the SAS assumes the type the first time you see the variable, as the first P is 3 characters, it assumes that.

Take the test below that will work;

data t1;
     format P $4.;
     set TABELA;
     IF   RECEITA 1000000 AND  RECEITA_ LE 10000000 THEN
        P = '>1'||'M';
     ELSE IF  RECEITA 10000000 THEN
        P = '>10'||'M';
run;
    
20.10.2018 / 17:28