BookmarkSubscribeRSS Feed
Lordy
Obsidian | Level 7

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

4 REPLIES 4
ballardw
Super User

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.

 

Lordy
Obsidian | Level 7
How do we factor in the SSN and the date for each person
ballardw
Super User

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.

Lordy
Obsidian | Level 7
Sure thx

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!

How to Concatenate Values

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.

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
  • 4 replies
  • 876 views
  • 1 like
  • 2 in conversation