BookmarkSubscribeRSS Feed
chiyoung
Fluorite | Level 6

Hi all,

 

I'd like to ask u guys some questions related to SAS statistical method. (SQL, any code,,)

What I want to see is the percentage of food sales on a daily basis based on the data attached.

 

Please refer to information below to understand the attached file. I want to compare these three groups.

 

[Excel Sheet1]

1) Number of foods sold for same period with the intervention date of last year (Nov,19th 2018 ~ Dec, 14th 2018 / 4 weeks exclude Sat & Sun) - No intervention

2) Number of food sales before the intervention (Oct, 25th 2019 ~ Nov, 15th 2019 / 4 weeks exclude Sat & Sun) - No intervention

3) Number of food sales during the intervention (Nov,18th 2019 ~ Dec, 13th 2019 / 4 weeks exclude Sat & Sun) - Intervention

 

[Background]
I classified all foods in school cafeteria as nutrition score and put Alphabet score stickers on them during the intervention time. (A,B,C,D,E - A has the best nutrition composition). And I want to know how these nutri-score stickers affect people's consumption habit. I want to do interrupted time series analysis ultimately, but I want to see the ratio of each group before that. 

 

It will be much appreciated if u guys let me know how to solve this problem. This is for my thesis. 

Please feel free to comment on me if u have questions. 

 

fdfcd.pngscores@1_5x.pngdddd.JPG

1,2) Caculation system Nutri-Score

3) my key thesis' graph in harvard Univ.

(https://search.proquest.com/docview/1820592544?rfr_id=info%3Axri%2Fsid%3Aprimo)

 

7 REPLIES 7
PaigeMiller
Diamond | Level 26

Most of us will not download Excel files (or other Microsoft Office files) because they are a security risk.

 

Please provide a portion of your data as a SAS DATA step.

 

PROC FREQ calculates percentages of each group.

--
Paige Miller
chiyoung
Fluorite | Level 6

proc sql;
create table posco1 as
select *, sum(ea) as sum_ea
from posco
group by grade,day
;

 

 

ddddddccc.JPG

 

fdfasdfsasdfsa.JPG

 

gfdsgsdfgsfg.JPG

 

 

Thank you for your answer. 

PaigeMiller
Diamond | Level 26

I cannot work with data in a screen capture. The specific request was "Please provide a portion of your data as a SAS DATA step." Here are Instructions: How to create a data step version of your data AKA generate sample data for forums

 

What is the EXACT calculation you want to do with this data? Your PROC SQL code does not compute percents, what is the numerator and what is the denominator of the percent that you want?

--
Paige Miller
chiyoung
Fluorite | Level 6
proc sql;
create table posco1 as
select *, sum(ea) as sum_ea
from posco
group by grade,day 
;

proc sort data = posco1 out = posco2 nodupkey;
by grade sum_ea;
run;


proc sql;
create table posco2 as
select *, sum_ea / sum(sum_ea) * 100 as percent
from posco1
group by day
quit;

 

I made this mistake because I wasn't used to it.
I'm so sorry to bother you.

PaigeMiller
Diamond | Level 26

@chiyoung wrote:
proc sql;
create table posco1 as
select *, sum(ea) as sum_ea
from posco
group by grade,day 
;

proc sort data = posco1 out = posco2 nodupkey;
by grade sum_ea;
run;


proc sql;
create table posco2 as
select *, sum_ea / sum(sum_ea) * 100 as percent
from posco1
group by day
quit;

 

Also, I am calculating each ratio in this way. 


It seems as if you have answered your own question. Or am I misunderstanding something?

--
Paige Miller
chiyoung
Fluorite | Level 6
data WORK.POSCO;
  infile datalines dsd truncover;
  input day:DATE9. grade:$2. ea:32.;
  format day DATE9.;
  label day="day" grade="grade" ea="ea";
datalines;
19NOV2018 a 5
19NOV2018 a 38
19NOV2018 a 4
19NOV2018 a 10
19NOV2018 a 6
19NOV2018 a 30
19NOV2018 a 0
19NOV2018 a 5
;

 

I made this mistake because I wasn't used to it.
I'm so sorry to bother you. 

Reeza
Super User

Given what you've posted, consider PROC FREQ.

It calculates the percentages automatically. So what you need to figure out is how to filter your data set but the percentage part is trivial. If you cannot provide real data that's understandable, instead generalize your problem and consider using datasets from SASHELP library, which are available to all SAS users instead. 

 

proc freq data=sashelp.cars;
table origin;
run;

@chiyoung wrote:

Hi all,

 

I'd like to ask u guys some questions related to SAS statistical method. (SQL, any code,,)

What I want to see is the percentage of food sales on a daily basis based on the data attached.

 

Please refer to information below to understand the attached file. I want to compare these three groups.

 

[Excel Sheet1]

1) Number of foods sold for same period with the intervention date of last year (Nov,19th 2018 ~ Dec, 14th 2018 / 4 weeks exclude Sat & Sun) - No intervention

2) Number of food sales before the intervention (Oct, 25th 2019 ~ Nov, 15th 2019 / 4 weeks exclude Sat & Sun) - No intervention

3) Number of food sales during the intervention (Nov,18th 2019 ~ Dec, 13th 2019 / 4 weeks exclude Sat & Sun) - Intervention

 

[Background]
I classified all foods in school cafeteria as nutrition score and put Alphabet score stickers on them during the intervention time. (A,B,C,D,E - A has the best nutrition composition). And I want to know how these nutri-score stickers affect people's consumption habit. I want to do interrupted time series analysis ultimately, but I want to see the ratio of each group before that. 

 

It will be much appreciated if u guys let me know how to solve this problem. This is for my thesis. 

Please feel free to comment on me if u have questions. 

 

fdfcd.pngscores@1_5x.pngdddd.JPG

1,2) Caculation system Nutri-Score

3) my key thesis' graph in harvard Univ.

(https://search.proquest.com/docview/1820592544?rfr_id=info%3Axri%2Fsid%3Aprimo)

 


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 2195 views
  • 2 likes
  • 3 in conversation