Lesson 9, 3.24 Practice

22 views
Skip to first unread message

Sudha

unread,
Mar 12, 2015, 5:08:45 PM3/12/15
to anova...@googlegroups.com
Level 2 Practice:
This is the code i Wrote after defining orion library.

data work.season;
set orion.customer_dim;
length Promo Promo2 $6;
qtr=qtr(customer_birthdate);
if qtr=1 then Promo="Winter";
else if qtr=2 then Promo="Spring";
else if qtr=3 then Promo="Summer"
else if qtr=4 then Promo="Fall";
if customer_age>=18 and customer_age<=25 then promo2="YA";
else if customer_age>=65 then promo2="Senior";
else promo2="Missing";
keep customer_firstname customer_lastname 
customer_birthdate customer_age promo promo2;
run;

proc print data=work.season;
run;

I am getting an error and this is what the log says:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
57
58 data work.season;
59 set orion.customer_dim;
60 length Promo Promo2 $6;
61 qtr=qtr(customer_birthdate);
62 if qtr=1 then Promo="Winter";
63 else if qtr=2 then Promo="Spring";
64 else if qtr=3 then Promo="Summer"
65 else if qtr=4 then Promo="Fall";
____
388
76
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
66 if customer_age>=18 and customer_age<=25 then promo2="YA";
67 else if customer_age>=65 then promo2="Senior";
68 else promo2="Missing";
69 keep customer_firstname customer_lastname
70 customer_birthdate customer_age promo promo2;
71 run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SEASON may be incomplete. When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set WORK.SEASON was not replaced because this step was stopped.

Amruta Kirtane

unread,
Mar 12, 2015, 6:26:04 PM3/12/15
to anova...@googlegroups.com
; after summer missing

Laxmi Chaudhary

unread,
Mar 12, 2015, 6:38:06 PM3/12/15
to anova...@googlegroups.com
Hi Sudha,

Try this code...

data work.season;
set orion2.customer_dim;
length Promo Promo2 $6;
qtr=qtr(customer_birthdate);
if qtr=1 then Promo="Winter";
else if qtr=2 then Promo="Spring";
else if qtr=3 then Promo="Summer";    /* you missed ' ;'  for this statement.*/

Laxmi Chaudhary

unread,
Mar 12, 2015, 6:41:05 PM3/12/15
to anova...@googlegroups.com
Hi Sudha,

Try this code...

data work.season;
set orion.customer_dim;
length Promo Promo2 $6;
qtr=qtr(customer_birthdate);
if qtr=1 then Promo="Winter";
else if qtr=2 then Promo="Spring";
else if qtr=3 then Promo="Summer"; .... /* you missed ' ;'  for this statement.*/

Sudha

unread,
Mar 13, 2015, 7:49:03 AM3/13/15
to anova...@googlegroups.com
Thank u!
Reply all
Reply to author
Forward
0 new messages