Ok. I decided to use proc report also to review that. Everything is great, but to be nitpicky, I still have missing data (.) for the data points for Partnumber and Quantity (in Sales) and for Date and Amount (in Inventory). This is simply because, of course, that data did not apply to each respective category. To make the report look nice, it would be best to remove the mssing rows. If it can be done, great, if not, I have learned a lot from this example already., Thanks. Here is my code: ------------------------- /* Chapter 21 Problem 21.10*/ Libname Learn'/folders/myfolders/SASData' ; Data Sales(keep = Date Amount) Inventory(keep = Partnumber Quantity) ; infile '/folders/myfolders/SASData/mixed_recs.txt' pad ; Input @16 Code 2. @ ; If Code eq 1 then do ; Out = Sales ; input @1 Date mmddyy10. @12 Amount 4. ; format Date mmddyy10. ; end ; Else if Code ne 1 then do ; Out = Inventory ; input @1 PartNumber $ 6. @8 Quantity 3. ; end ; run ; Title 'Sales' ; proc report data=Sales ; column Date Amount ; define Date / display "Date" width=5 ; define Amount / display "Amount" width=5 ; run ; Title 'Inventory' ; proc report data=inventory ; column Partnumber Quantity ; define Partnumber / display "Part Number" width=5 ; define Quantity / display "Quantity" width = 5 ; run ; -------------------- Here are the results Sales Date Amount 10/21/2005 100 11/15/2005 200 . . . . 01/03/2005 5000 . . Inventory Part Number Quantity . . A13688 250 B11112 300 . A88778 19
Read my post again, thoroughly. In particular note how output is directed to datasets. With your data step, all records are written to both datasets, and so you get missing values in half of them, when variables are not read by an input statement.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.