Hi,
I am creating a new column called "group" in my dataset based on the value of another column. The real code I run has many more if conditions but the "group" column has only 3 values; indeterminate, not performance, performance.
In the output, I have "not performan" rather than "not performance". Why do I have the last 2 letters dropped and how do I fix it?
data mydata;
set mydata;
if reason = "asd asd asd" then group = "indeterminate";
if reason = "abc abc abc" then group = "indeterminate";
if reason=" xxx" then group="not performance";
if reason=" yy " then group="performance";
else cancellation_grouping = "other";
run;
Thanks
Hello,
Length of GROUP variable is decided upon when GROUP gets its first value.
If first value assigned is 'ABC' then length becomes 3 and all other values (assigned later) are truncated as from the 4th position.
You can change the way length is determined by explicitly specifying the length yourselves for GROUP variable, like here :
data mydata;
LENGTH group $ 15;
set mydata;
if reason = "asd asd asd" then group = "indeterminate";
if reason = "abc abc abc" then group = "indeterminate";
if reason=" xxx" then group="not performance"; if reason=" yy " then group="performance";
else cancellation_grouping = "other";
run;
/* end of program */
Koen
Hello,
Length of GROUP variable is decided upon when GROUP gets its first value.
If first value assigned is 'ABC' then length becomes 3 and all other values (assigned later) are truncated as from the 4th position.
You can change the way length is determined by explicitly specifying the length yourselves for GROUP variable, like here :
data mydata;
LENGTH group $ 15;
set mydata;
if reason = "asd asd asd" then group = "indeterminate";
if reason = "abc abc abc" then group = "indeterminate";
if reason=" xxx" then group="not performance"; if reason=" yy " then group="performance";
else cancellation_grouping = "other";
run;
/* end of program */
Koen
Hello,
Can you post the LOG?
Copy the LOG , click on the </> icon in the toolbar on top when replying , then paste LOG in pop-up window!
Also, you might want :
if ; else if ; else if ; else if ; else ;
instead of 4 times if + an else ?
Thanks,
Koen
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.