BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ManitobaMoose
Quartz | Level 8
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
Kurt_Bremser
Super User

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 16 replies
  • 3871 views
  • 0 likes
  • 4 in conversation