BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

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?

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

will this help?

if txtype ne quote_credit then do;
policy_credit=creditedby;
call missing(quote_credit);
end;

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20

will this help?

if txtype ne quote_credit then do;
policy_credit=creditedby;
call missing(quote_credit);
end;
alepage
Barite | Level 11

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.

 

novinosrin
Tourmaline | Level 20

post a sample of your input data and your wanted output

alepage
Barite | Level 11

I have found my mistake.

 

Thanks!

ballardw
Super User

"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'.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 3232 views
  • 0 likes
  • 3 in conversation