Dear Tom, Thank you so much for your reply to my post and for all your work. I can't get the first part of the code to work. I tested this code with the RJ Macready.csv file that I uploaded in my initial post on this thread. When I run the code, I receive an error message which I am posting below. I have narrowed the error message down to the following part of the code by systematically omitting sections of the do loop until I receive the error message: input time @; do i=1 to n ; input hr @; date=d(i); if hr not in (.,999) then output; end; Here is the full error message including all relevant code: 483 484 %let pathname=P:\PTSD\18. Analysis\Test/* C:\data */; 485 data tall ; 486 length filename fname $256 ; 487 infile "&pathname\*.csv" dsd truncover filename=fname ; 488 array d (1000) _temporary_ ; 489 length Time Date HR 8 ; 490 informat time time. date mmddyy. ; 491 format time time5. date yymmdd10. ; 492 length dummy $8 ; 493 input @; 494 filename=scan(fname,-1,'./\') ; 495 if filename ne lag(filename) then do ; 496 input dummy @ ; 497 do n=1 by 1 until (date=.); 498 input date @; 499 d(n)=date ; 500 end; 501 n=n-1; 502 input; 503 end; 504 input time @; 505 do i=1 to n ; 506 input hr @; 507 date=d(i); 508 if hr not in (.,999) then output; 509 end; 510 run; NOTE: The infile "P:\PTSD\18. Analysis\Test\*.csv" is: Filename=P:\PTSD\18. Analysis\Test\RJ Macready.csv, RECFM=V,LRECL=32767 ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, or invalid. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--- 3 0:00,999,999,999,999,999,999,999,999,999,999,83,100,62,66,69,74,73,70,82,75,67,78,61,77, 89 68,70,86,86,79,63,92,67,83,73,68,60,64,59,58,83,110,999,999,999,999,999,999,999,999,999, 177 999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999, 265 999,999,999,999,999,999,999,999,999,999,999,999,999,999,82,999,52,53,83,63,54,52,59,47,6 353 2,55,68,69,55,65,53,69,49,59,77,76,59,59,70,54,59,60,69,63,53,66,45,51,56,999,999,999,99 441 9,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,99 529 9,999,999,999,999,999,84,999,59,57,64,59,78,58,61,64,60,65,67,72,133,105,58,78,61,67,65, 617 63,62,61,58,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999, 705 999,999,999,999,999,999,999,999,999,999,999,999,57,999,999,999,999,999,999,999,999,999,9 793 99,999,70,56,67,51,60,67,98,72,56,61,55,51,56,64,83,70,62,64,55,58,56,60,60,84,65,66,66, 881 70,70,70,70,70,70,70,999,999,999,999,999,999,999,114,103,63,70,59,115,78,76,76,65,63,64, 969 72,100,70,73,63,77,59,68,63,69,64,96,66,82,76,64,71,61,75,86,70,58,65,71,69,63,68,72,92, RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--- 1057 67,85,69,67,73,74,77,75,63,69,61,64, 1092 filename=csv fname=P:\PTSD\18. Analysis\Test\RJ Macready.csv Time=0:00 Date=. HR=. dummy= n=. i=1 _ERROR_=1 _N_=2 NOTE: 3 records were read from the infile "P:\PTSD\18. Analysis\Test\*.csv". The minimum record length was 315. The maximum record length was 3156. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.TALL may be incomplete. When this step was stopped there were 0 observations and 7 variables. WARNING: Data set WORK.TALL was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.00 seconds I would really appreciate any help you may have. I am trying to solve the problem myself. Thanks again for your help. Sincerely, Ian
... View more