Variable length - SAS

Asked

Viewed 1,096 times

0

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

Code Example:

    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’ve tried the functions like cat and substr, and even just declare, for example, P = ">10M", but the same problem happens.

1 answer

0

You must inform that P has 4 Strings characters, because SAS takes the type the first time you see the variable, as the first P is 3 characters, it assumes this.

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;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.