DATA Work.TestData2; *do not use the same name in DATA and SET statements. This makes it very hard to debug;
SET Work.TestData;
IF missing(ItemType) and FINDW(Description, 'Flatbread', 'i')>0 then ItemType = 'Sandwich';
RUN;
Try this.
Note a few changes:
1. Item_TYPE to ItemTYpe - you seem to be using both but your data shows ITemType, not underscore. If this was the case the log would likely have an error about uninitialized variable.
2. Replace testDATA in DATA statement (first line) so that it's easier to debug the code
3. Remove IF/THEN since not needed
4. Added 'i' modifier to FIND to allow it to ignore the case of the world flatbread.
Let me know if this works and if it doesn't post the full log.
Documentation on the FIND function is here:
https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p16rdsa30vmm43n1ej4936nwa01t.htm...
@Yosef20 wrote:
What dataset looks like now:
ItemNumber Description ItemType
1 Double Flatbread | <blank>
with chicken
2 Regular Bacon ... | Sandwich
3 Regular Turkey/Ham | Sandwich
- There are also ItemTypes such as salads, chips, cookies, add ons etc. but I am only testing sandwiches right now.
Example of what output dataset should look like:
ItemNumber Description ItemType
1 Double Flatbread Sandwich
with chicken
etc.
Test Code (doesn't work):
DATA Work.TestData;
SET Work.TestData;
IF Item_Type = '' then DO;
IF FINDW(Description, 'Flatbread')>0 then Item_Type = 'Sandwich';
END;
RUN;
The last forum I found the FINDW command was not very helpful in explaining the structure of it so I don't know if I even started doing it correctly.
Thank you for the help, if there is more code or data that you need to see I can get it.