Ok. That makes sense. The do loop needs to be included, and this works. Thanks. There is one more important thing... I need to create separate printouts for Sales and Inventory. In the past , when using an if... then statement, without the do loop, the output created a new data set I could then print. But this does not work when the output= is used withing a do loop, Also, when I try to create the output sets, that is not working either. Finally, the mmddyy10. format does not do anything. The Date in the output window stays in the SAS numerical form, rather than the desired format. This has been frustrating. Any help would be appreciated. Below is my adjusted code: -------------------------------- /* Chapter 21 Problem 21.10*/ Libname Learn'/folders/myfolders/SASData' ; Data Prob21_10 ; infile '/folders/myfolders/SASData/mixed_recs.txt' pad ; input @16 Code 2. @ ; If Code eq 2 then do Output = Sales ; input @1 PartNumber $ 5. @8 Quantity 3. ; end ; Else if Code ne 2 then do Output = Inventory ; input @1 Date mmddyy10. @11 Amount 5. ; format Data mmddyy10. ; end ; run ; Data Mixed ; Set Work.Prob21_10 ; If Code eq 2 then Output Sales ; Else if Code ne 2 then Output Inventory ; run ; Title 'Sales' ; proc print data=Sales noobs ; run ; Title 'Inventory' ; proc print data=Inventory noobs ; run ; ------------------------------------------- Below is the Log: 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 61 62 /* Chapter 21 63 Problem 21.10*/ 64 Libname Learn'/folders/myfolders/SASData' ; NOTE: Libref LEARN was successfully assigned as follows: Engine: V9 Physical Name: /folders/myfolders/SASData 65 66 Data Prob21_10 ; 67 infile '/folders/myfolders/SASData/mixed_recs.txt' pad ; 68 input @16 Code 2. @ ; 69 If Code eq 2 then do 70 Output = Sales ; 71 input @1 PartNumber $ 5. 72 @8 Quantity 3. ; 73 end ; 74 75 76 Else if Code ne 2 then do 77 Output = Inventory ; 78 input @1 Date mmddyy10. 79 @11 Amount 5. ; 80 format Data mmddyy10. ; 81 end ; 82 run ; NOTE: Variable Sales is uninitialized. NOTE: Variable Inventory is uninitialized. NOTE: Variable Data is uninitialized. NOTE: The infile '/folders/myfolders/SASData/mixed_recs.txt' is: Filename=/folders/myfolders/SASData/mixed_recs.txt, Owner Name=sasdemo,Group Name=sas, Access Permission=-rw-rw-r--, Last Modified=23Aug2017:10:33:41, File Size (bytes)=106 NOTE: 6 records were read from the infile '/folders/myfolders/SASData/mixed_recs.txt'. The minimum record length was 16. The maximum record length was 16. NOTE: The data set WORK.PROB21_10 has 6 observations and 9 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.02 seconds 83 84 Data Mixed ; 85 Set Work.Prob21_10 ; 86 If Code eq 2 then Output Sales ; _____ 455 87 Else if Code ne 2 then Output Inventory ; _________ 455 ERROR 455-185: Data set was not specified on the DATA statement. 88 run ; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.MIXED may be incomplete. When this step was stopped there were 0 observations and 9 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds 89 90 Title 'Sales' ; 91 proc print data=Sales noobs ; ERROR: File WORK.SALES.DATA does not exist. 92 run ; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 93 94 Title 'Inventory' ; 95 proc print data=Inventory noobs ; ERROR: File WORK.INVENTORY.DATA does not exist. 96 run ; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 97 98 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 111
... View more