Hello,
I have a dataset with few variables. 4 of those (string variables) are:
createdby
policy_credit
quote_credit
txtype.
When txtype ne 'quote' I would like to take the value of creditedby and put it into policy_credit then set quote_credit to empty.
Data Soumweb1A;
set SoumWeb1;
if txtype eq 'policy' then policy_credit = updatedby;
run;
This code is note working, Why?
will this help?
if txtype ne quote_credit then do;
policy_credit=creditedby;
call missing(quote_credit);
end;
will this help?
if txtype ne quote_credit then do;
policy_credit=creditedby;
call missing(quote_credit);
end;
I have try your code and it is not working
I have try the following
if txtype ne quote_credit then do;
policy_credit='test' ;
end;
and it works. But for some reason I don't know, I am not able to assign the value of creditedby to policy_credit.
creditedby = 'aaa1234';
Any idea why.
post a sample of your input data and your wanted output
I have found my mistake.
Thanks!
"Not working" is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
What is the value of the variable updatedby? What type is it (numeric or character) and what is its length? And why are you using it instead of creditedby (or possibly createdby)?
What type of variable is policy_credit (numeric or character) and what is its length?
What type of variable is creditedby (or is this supposed to be createdby) (numeric or character) and what is its length?
Types are important as numeric variables can't contain text. Text variables can be assigned values from numeric but the conversion may leave something to be desired depending on values and variable properties. If the text variable has a length of 3 and you try to stuff more characters into it from a longer variable the values will be truncated. With no error or warning.
I am assuming that you are actually using a value of "policy" that exists in your data variable txtype. Note that a policy number like 'abc123' is not equal to 'ABC123'.
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.