LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2004, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 23 Apr 2004 10:25:47 +1000
Reply-To:     Philip_Crane@WORKCOVER.VIC.GOV.AU
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Philip_Crane@WORKCOVER.VIC.GOV.AU
Subject:      Re: Retaining values in a dataset
Comments: To: Brad Jennings <bjennings@LBMC.COM>
Content-type: text/plain; charset="us-ascii"

Brad,

The following will do as you ask provided the data set is exactly as shown with 3 and only 3 lines for every item. Based on the type of item the select statement assigns price to a new variable. Output only happens when a Tax line is encounted.

Philip

data invoice; length invc_nb $ 6 line_ty $ 7; input @01 invc_nb @15 item @26 price @38 qty @48 line_ty; cards; ABC876 123 54.46 1 Item ABC876 3.54 Freight ABC876 .98 Tax ABC876 456 54.46 1 Item ABC876 3.54 Freight ABC876 .98 Tax ABC976 456 54.46 2 Item ABC976 3.54 Freight ABC976 1.96 Tax ; run;

data invoice(keep=invc_nb item_cd item_ct item_am freight_am tax_am); retain invc_nb item_cd item_ct item_am freight_am tax_am; set invoice; select(line_ty); when ('Item') do; item_am = price; item_cd = item; item_ct = qty; end; when ('Freight') freight_am = price; when ('Tax') do; tax_am = price; output; end; end;

proc print; run;

Brad Jennings <bjennings@LBMC.C To: SAS-L@LISTSERV.UGA.EDU OM> cc: Sent by: "SAS(r) Subject: Retaining values in a dataset Discussion" <SAS-L@LISTSERV.U GA.EDU>

23/04/2004 08:06 AM Please respond to Brad Jennings

I have an existing dataset that contains multi-line records.

Invoice Item Price Qty Type ABC876 123 54.46 1 Item ABC876 3.54 Freight ABC876 .98 Tax ABC876 456 54.46 1 Item ABC876 3.54 Freight ABC876 .98 Tax

etc.

This is an existing SAS dataset. I'm trying to retain the item number, item price, item quantity, freight price down to the tax line so that the last record in the invoice/item grouping will contain the item price, item freight, and item tax. From here I can delete all records except the last one in the invoice/item grouping to leave me with a single record with invoice and item details.


Back to: Top of message | Previous page | Main SAS-L page