Hello,
I'm running this piece of code, but even though here it says LEAD, in the output it shows up as LEA. Why is the flag value getting cut off?
This is the first instance of the variable flag that SAS encounters, so it's not even that the size of flag is being set before by some other value. Appreciate the help. Thanks!
data abc;
set abc;
if stage in ('45','35') then flag="LEAD";
run;
It might be that flag already exists in dataset abc.
Add the statement
length flag $8;
before the set statement.
It is possible that the issues is with a format that is attached to the variable. Changing the length will not change the format attached. So if you force the length to by 8 bytes but it still has $3 format attached to it then only the first three characters will show on printouts.
Then try
data abc;
set abc(drop=flag);
if stage in (45, 35) then flag="LEAD";
run;
@AJ_Brien wrote:
Hello,
I'm running this piece of code, but even though here it says LEAD, in the output it shows up as LEA. Why is the flag value getting cut off?
This is the first instance of the variable flag that SAS encounters, so it's not even that the size of flag is being set before by some other value. Appreciate the help. Thanks!
data abc; set abc; if stage in ('45','35') then flag="LEAD"; run;
If you ran this code more than once then you do have the variable flag in the data set ABC because you placed it there.
This is a side effect of using the
Data abc;
set abc;
code structure. The first time you ran that code and there were no errors preventing the execution you completely replaced the data set.
If you previously ran the code with a logic error such as:
if stage in ('45','35') then flag="LEA";
then you created a text variable with a length of 3.
When testing recoding of variables always send the output to a different data set so you do not corrupt your starting data.
Also post your log with code and any messages together into a code box.
Something else: define "getting cut off". How are you seeing a "cut off" value? Did you Print the data set (or at least that variable)? Put statement in the data step? Something else?
Have you run Proc contents on the data set to tell you what the properties of the variable Flag might be? Perhaps somehow it acquired a format of $3. limiting what value will display in either a viewtable or printed output.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.