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 (October 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 16 Oct 2003 18:09:31 -0700
Reply-To:   Harmeet <hkalra@WEBGABLE.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Harmeet <hkalra@WEBGABLE.COM>
Organization:   http://groups.google.com
Subject:   Looking for a better way of doing this - Setting two dataset then retaining some fields ...
Content-Type:   text/plain; charset=ISO-8859-1

I am looking for a better way of coding the following, if this is an average coding style then please let me know. I used to code in SAS then I did not code for last 4 years and now I am back. (I could not live without SAS.......:)

I need to concatenate two datasets one has all the reqt numbers(REQT), customer address info and the invoice types - multiple records(one invoice type per record) and other dataset has all the invoice types printed in a dataset with request number information on every line of the invoice. I need to print one letter per request number with all the invoice types listed on the letter and then associated invoices behind the letter. In the invoice file INV I have: reqtno and invline(invoice line) and Linelength, invoice number and invoice line number:

So there are multiple records per reqt number in the REQT file and there are multiple records in the INV file; invoice file does not have invoice type information it is already sorted in the request number and, invoice number and invoice line number.

All the customer address related information is on every record in the REQT file. I need to retain the customer name, address information and then as soon as I get to the first invoice record for that request I need to generate the cover letter.

This is kind of mailmerge:

Here is the simplified skeleton .......... (I can have reqts without invoices. and I do have multiple templates for the letters ... ...)

proc sort data=reqt; by reqtno invtype;

proc sort data=inv; by reqtno invno invlnno;

Data _null_ retain cvlflag '0'; set reqts(in=master) invoices (in=inv); by reqtno ;

if master then do; if first.reqtno then do; cvrflag = 0 Link _RETAIN; === end; else do; code lines; end;

** the last.reqtno is needed just incase there was no invoice for the ** request number - I still need to gen the letter ---

if last.reqtno then do;============ _genltr; end;

end; *** Now we are accessing Invoice related to the reqt ****; if inv then do; if cvlflag = 0; then link _genltr;

put invline $varying Linelen. =====================

end;

return;

_genltr:

cvlflag=1;

====== return;

_Retain: length _custnm _custad1 _custad2 _cusad3 $42; retain _custnm _custad1 _custad2 _cusad3 ' ';

_custnm = custname; _cusad1 = custad1; _custad2 = custad2;

===========

return;


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