I have a dataset with Excercise (options - C1, C2), Dates, SSN, drinks (options - coke, sprite).
I want to flag a client who on the same day he excercises also buys either coke, sprite or both drinks.
Any help with sas codes please
One generic answer is in a data step something like
if exercisevariable = value and drinksvariable in (cokevalue, spritevalue) then flag= 1;
with out knowing 1) actual variable names, 2) actual variable values it is hard to get more specific.
Time to provide some example start data and what you want for a result. PLEASE do not provide any actual SSN values.
And it is best to provide example data in the form of a data step that replicates all of the properties of your data. 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.
Without such details we have to make assumptions about your data and could arrive at solutions that do not work because it relies on the value being one type and your actual data is a different type.
You would need to provide examples of how you think you want to use the dates, probably needing to ensure that your DATES are SAS date valued variables.
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.