Hello, I'm working on the same question posted on this page.
I've ran the code and I keep receiving the same error code. I need help being pointed in the right direction.
DATA WORK.BAKERYSALES ;
INFILE '/home/emilymoore20/EPG194/output/myTestFolder/BSA570v4_Week4_assignment_data.txt' DELIMITER = '|' MISSOVER DSD LRECL=32767 FIRSTOBS=2 ;
/* INFORMAT statements do what? sales, month, subtotals, grand total */
INFORMAT strDate $30. ;
INFORMAT product best32. ;
INFORMAT sales nlnum32. ;
/* FORMAT statements do what? dates */
FORMAT strDate $30. ;
FORMAT product best12. ;
FORMAT sales nlnum12. ;
INPUT
strDate $
product
sales
;
Are we supposed to guess what the error you keep getting is? or did you plan to tell us?
Copy the lines from the SAS log for the whole data step including the error messages. Remember to click on the Insert Code button on the editor menu (looks like < / > ) and paste the lines into the pop-up that appears.
The error I keeping getting is there 1 unclosed DO block
DO
date3 = SUBSTR(strDate, dateCommaFinder+2);
dateSpaceFinder=INDEX(date3, ' ');
month = SUBSTR(date3, 1, dateSpaceFinder);
SELECT (month);
WHEN ('January') mnth=01;
WHEN ('February') mnth=02;
WHEN ('March') mnth=03;
WHEN ('April') mnth=04;
WHEN ('May') mnth=05;
WHEN ('June') mnth=06;
WHEN ('July') mnth=07;
WHEN ('August') mnth=08;
WHEN ('September') mnth=09;
WHEN ('October') mnth=10;
WHEN ('November') mnth=11;
WHEN ('December') mnth=12;
OTHERWISE mnth=.;
END;
You are missing a semicolon on the DO statement.
The END at the end closes the select group, you need another END statement after that to close the DO group.
You really need to take more care in reading our answers to your posts and doing what we ask you to do.
You were asked to
DATA new; SET bakerysales; dateSlashFinder=FIND(strDate,"/"); dateCommaFinder=INDEX(strDate, ','); FORMAT productSales COMMA20.; FORMAT productName $30.; FORMAT date MMDDYY10.; /* REPLACE THIS COMMENT TEXT TO ANSWER THE QUESTION: What is the if/else statement accomplishing? Your answer should be specific and complete, and describe (among other things) the purpose of the DO loop.*/ IF dateCommaFinder = 0 THEN DO date = input(strDate,MMDDYY10.); FORMAT date MMDDYY10.; day = day(date); mnth=month(date); year=year(date); END;
And if you need to solve the same homework assignment that was mentioned in the original thread, then you should first let us know your answers. We can then offer corrections if we find mistakes.
Note that the code as posted in this thread is syntactically complete and correct. You need to copy/paste it as is to run it successfully.
Correction: this is not true. Both DO statements miss a semicolon.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.