Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Creating a local macro


From   Mosi Ifatunji <ifatunji@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Creating a local macro
Date   Mon, 10 Dec 2012 17:51:37 -0500

Dear All:
 
Per the attached file, is there a way to create some sort of local macro then obain total values for the items in the macro list.
 
For example, how would I create a local macro called "meal1" such that it includes "dairy3 green3 grain3 fruit3 protein3"? These variables are cases in the dataset. That is, they run down the far left column. The variables for these cases are things like protein, fat etc.
 
Given that I have successfully bundled these five items in some fashion, how do I obain the total calories, total carbs, total fiber, total calcium.
 
thanks for your assistance.


food,serving,type,calories,protein,carbs,fat,fiber,calcium,Diet,diet
Milk,8,Dairy,72,100,23,54,12,234,,
cheese,4,Dairy,12,64,11,8,1,176,,
dairy3,4,Dairy,36,50,12,27,6,117,,
dairy4,4,Dairy,2,13,2,2,0,35,,
dairy5,4,Dairy,31,57,12,23,5,141,,
apple,8,Fruit,10,15,5,0,33,4,American,Organic
orange,8,Fruit,2,4,3,3,47,95,American,Organic
fruit3,8,Fruit,5,8,3,0,17,2,American,Organic
fruit4,8,Fruit,0,1,1,1,9,19,American,Organic
fruit5,8,Fruit,4,7,3,1,26,30,American,Organic
oatmill,8,Grain,2,59,7,0,75,29,American,Organic
popcorn,16,Grain,127,97,15,2,43,61,American,Organic
grain3,16,Grain,1,30,4,0,38,15,American,Organic
grain4,16,Grain,25,19,3,0,9,12,American,Organic
grain5,16,Grain,39,51,7,1,41,29,American,Organic
string bean,8,green,5,32,17,2,17,5,American,Organic
lettuce,8,green,5,16,1,0,64,83,American,Organic
green3,8,green,3,16,9,1,9,3,American,Organic
green4,8,green,1,3,0,0,13,17,American,Organic
green5,8,green,3,17,7,1,26,27,American,Organic
beef sirloin steak lean only broiled,4,Protein,207,35,0,7,0,23,Mexican,Organic
chick breast skinless baked,10,Protein,123,29,9,13,0,12,Mexican,Organic
meat3,10,Protein,104,17,0,3,0,11,Mexican,Organic
meat4,10,Protein,25,6,2,3,0,2,Mexican,Organic
meat5,10,Protein,115,22,3,6,0,12,Mexican,Organic


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index