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

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Kurt_Bremser
Super User
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.

Reeza
Super User

You're looking for summary functions. 

 

SAS SQL and PROC MEANS are two standard way to obtain descriptive statistics and aggregate data.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 840 views
  • 2 likes
  • 4 in conversation