From: mark on 5 Mar 2010 22:20 hI All , I ant to create three new column variables :- Week , Revenues and SameDayDelivery from the column variables given in the data sales.The code i used is - data weekly_sales_revenues; set sales; IF "01/11/2009" <= DateofSale < "08/11/2009" THEN Week = "Week1"; Else IF "08/11/2009" <= DateofSale < "15/11/2009" THEN Week = "Week2"; Else IF "15/11/2009" <= DateofSale < "22/11/2009" THEN Week = "Week3"; ELSE IF "22/11/2009" <= DateofSale < "29/11/2009" THEN Week = "Week4"; IF TimeofSale <= '15:00' THEN SameDayDelivery = 'Yes'; ELSE SameDayDelivery = 'No'; IF Laptopmodel="AT3600" then do; IF warranty=1 then revenue=UnitsSold*(1199.99+39); IF warranty=0 then revenue=UnitsSold*1199.99; if Laptopmodel="AP3965" then do; if DateofSale < '15/11/2009' and warranty=1 then revenue=UnitsSold*(699.99+39); else if DateofSale < '15/11/2009' and warranty=0 then revenue=UnitsSold*(699.99); if DateofSale >= '15/11/2009' and DateofSale < '29/11/2009' and warranty=1 then revenue=UnitsSold*(499.99+39); else if DateofSale >= '15/11/2009' and DateofSale < '29/11/2009' and warranty=0 then revenue=UnitsSold*(499.99); proc print data = weekly_sales_revenues; run; The error :- 736 revenue=UnitsSold*(499.99+39); 1737 else if DateofSale >= '15/11/2009' and DateofSale < '29/11/2009' and warranty=0 then 1738 revenue=UnitsSold*(499.99); 1738 revenue=UnitsSold*(499.99); - 117 ERROR 117-185: There were 2 unclosed DO blocks. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.WEEKLY_SALES_REVENUES may be incomplete. When this step was stopped there were 0 observations and 9 variables. WARNING: Data set WORK.WEEKLY_SALES_REVENUES was not replaced because this step was stopped. Any suggestions. Kind Regards , markc
From: Patrick on 6 Mar 2010 10:45 Mark Same as already said here: http://support.sas.com/forums/thread.jspa?threadID=8905&tstart=0 You have seriously to start learning the SAS basics and also read what people suggest you to read, i.e: http://groups.google.com/group/comp.soft-sys.sas/browse_thread/thread/b2d6854c62d04a54/db2caae2c274fb86#db2caae2c274fb86 You get it so wrong with the dates that you've certainly not read what Ronald suggested. And with the "unclosed DO blocks" error: RTM! Regards Patrick
From: Nathaniel Wooding on 7 Mar 2010 11:30 Mark For each do statement, you have to have an "END;" statement. You have two Dos but no ends. Based on your code, you need them as indicated: IF Laptopmodel="AT3600" then do; IF warranty=1 then revenue=UnitsSold*(1199.99+39); IF warranty=0 then revenue=UnitsSold*1199.99; END; * THE FIRST END; if Laptopmodel="AP3965" then do; if DateofSale < '15/11/2009' and warranty=1 then revenue=UnitsSold*(699.99+39); else if DateofSale < '15/11/2009' and warranty=0 then revenue=UnitsSold*(699.99); if DateofSale >= '15/11/2009' and DateofSale < '29/11/2009' and warranty=1 then revenue=UnitsSold*(499.99+39); else if DateofSale >= '15/11/2009' and DateofSale < '29/11/2009' and warranty=0 then revenue=UnitsSold*(499.99); END; * THE SECOND ONE. Also, please go back and read my note to you that discusses how to work with dates in SAS. You may be very lucky and this code will work with the way that you specified the dates but it is as risky as crimping a fuse on a dynamite cap by hammering the the cap on a rock with a pair of pliers. Nat Wooding -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of mark Sent: Friday, March 05, 2010 10:21 PM To: SAS-L(a)LISTSERV.UGA.EDU Subject: Two Do Blocks in SAS hI All , I ant to create three new column variables :- Week , Revenues and SameDayDelivery from the column variables given in the data sales.The code i used is - data weekly_sales_revenues; set sales; IF "01/11/2009" <= DateofSale < "08/11/2009" THEN Week = "Week1"; Else IF "08/11/2009" <= DateofSale < "15/11/2009" THEN Week = "Week2"; Else IF "15/11/2009" <= DateofSale < "22/11/2009" THEN Week = "Week3"; ELSE IF "22/11/2009" <= DateofSale < "29/11/2009" THEN Week = "Week4"; IF TimeofSale <= '15:00' THEN SameDayDelivery = 'Yes'; ELSE SameDayDelivery = 'No'; IF Laptopmodel="AT3600" then do; IF warranty=1 then revenue=UnitsSold*(1199.99+39); IF warranty=0 then revenue=UnitsSold*1199.99; if Laptopmodel="AP3965" then do; if DateofSale < '15/11/2009' and warranty=1 then revenue=UnitsSold*(699.99+39); else if DateofSale < '15/11/2009' and warranty=0 then revenue=UnitsSold*(699.99); if DateofSale >= '15/11/2009' and DateofSale < '29/11/2009' and warranty=1 then revenue=UnitsSold*(499.99+39); else if DateofSale >= '15/11/2009' and DateofSale < '29/11/2009' and warranty=0 then revenue=UnitsSold*(499.99); proc print data = weekly_sales_revenues; run; The error :- 736 revenue=UnitsSold*(499.99+39); 1737 else if DateofSale >= '15/11/2009' and DateofSale < '29/11/2009' and warranty=0 then 1738 revenue=UnitsSold*(499.99); 1738 revenue=UnitsSold*(499.99); - 117 ERROR 117-185: There were 2 unclosed DO blocks. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.WEEKLY_SALES_REVENUES may be incomplete. When this step was stopped there were 0 observations and 9 variables. WARNING: Data set WORK.WEEKLY_SALES_REVENUES was not replaced because this step was stopped. Any suggestions. Kind Regards , markc CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
|
Pages: 1 Prev: Graph Help Next: Traffic lighting for character variables? |