Hi everyone,
I'm wondering if anyone has suggestions for how I could create some meal-level and school-level variables from a food-level file. More specifically,
- Input file is a food item-level file of about 200,000 food items, where each record has variables to indicate the school ID, weekday (num, 1-5), the meal (lunch/breakfast), the food category (five categories), and multiple variables to indicate nutrient contents for that food item. Since these are food-level files, any school-level and menu-level variables repeat for each food within a school or day.
How would I tell SAS to give me a variable of the minimum of a certain nutrient (ie lowest fat) at a specific school, on a day, during lunch meal, and within one food category. What kind of functions would I use to get to this school-level variable?
Due to the size and structure of the input file, I'm opting not to do a basic proc transpose at the beginning of this work to convert the food level file to a school - level one. I'm wondering if there s other data/proc? step processing I can do to get to where I need to.
Would you let me know if I should clarify?
Thank you!
Its hard to say, post a datastep with some test data,and what you want out. There is min(), arrays, retain etc. any of which could work.
Its hard to say, post a datastep with some test data,and what you want out. There is min(), arrays, retain etc. any of which could work.
proc sort
data=have (
where=(
school="school" and
weekday=X and
category="category" and
meal='Lunch'
)
)
out=want
;
by nutrient_content;
run;
The first observation would then be the one with the lowest content for your selection.
You're looking for summary functions.
SAS SQL and PROC MEANS are two standard way to obtain descriptive statistics and aggregate data.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.