BookmarkSubscribeRSS Feed
JDRII
Obsidian | Level 7

Hello, I'm working on the same question posted on this page.

https://communities.sas.com/t5/SAS-Programming/Analytics-amp-Programming/m-p/616734/highlight/false#...

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
;

 

7 REPLIES 7
Tom
Super User Tom
Super User

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.

JDRII
Obsidian | Level 7

The error I keeping getting is there 1 unclosed DO block

JDRII
Obsidian | Level 7

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;

PGStats
Opal | Level 21

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.

PG
Kurt_Bremser
Super User

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

  • post the WHOLE LOG of the WHOLE step; this includes the line numbers SAS reports
  • to use the </> button to open a window for posting such text; it's here: Bildschirmfoto 2020-04-07 um 08.32.59.png
JDRII
Obsidian | Level 7
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;
Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 7 replies
  • 813 views
  • 2 likes
  • 4 in conversation