LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 12 Jan 2000 19:41:07 -0500
Reply-To:     "Dorfman, Paul" <pdorfma@CITICORP.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Dorfman, Paul" <pdorfma@CITICORP.COM>
Subject:      Re: help with arrays
Comments: cc: "tazilla37@MY-DEJA.COM" <tazilla37@MY-DEJA.COM>
Content-Type: text/plain

David,

Not sure how much arrays can buy you in this particular case...but if you insist on using them to shorten the code, one out of a myriad possible variants is given below. As a side note, if you need a variable to assume the same value in all output records, it is perhaps better to assign the value once and forever in RETAIN than in each iteraion of a (double) loop.

data classes (keep=<...what you need...>); array class classa classb classc classe classf classg classh classm classn classp classr classt classu classv classy ; retain c '******' total 1; set jobs; jhrstr = hour(timepart(jstrtime)); jhrend = hour(timepart(jendtime)); do hour=jhrstr to jhrend; do over class; call vname (class, c); class = upcase(substr(c,6)) eq jobclass; end; output; end; run;

Kind regards, ===================== Paul M. Dorfman AT&T Universal Card Jacksonville, Fl =====================

David O., in part, wrote:

>I am presently trying to learn sas, i need help >with arrays. I have the following code and >would like to use an array to reduce the amount >of code, but have been unsuccessful. can anyone >help me with this code: >DATA CLASSES (KEEP = HOUR CLASSA CLASSB CLASSC >CLASSE CLASSF CLASSG >CLASSH CLASSM CLASSN CLASSP CLASSR CLASST >CLASSU CLASSV CLASSY TOTAL); >SET JOBS; >JHRSTR = HOUR(TIMEPART(JSTRTIME)); >JHREND = HOUR(TIMEPART(JENDTIME)); >DO HOUR = JHRSTR TO JHREND; >IF JOBCLASS = 'A' THEN CLASSA = 1; >IF JOBCLASS = 'B' THEN CLASSB = 1; >IF JOBCLASS = 'C' THEN CLASSC = 1; >IF JOBCLASS = 'E' THEN CLASSE = 1; >IF JOBCLASS = 'F' THEN CLASSF = 1; >IF JOBCLASS = 'G' THEN CLASSG = 1; >IF JOBCLASS = 'H' THEN CLASSH = 1; >IF JOBCLASS = 'M' THEN CLASSM = 1; >IF JOBCLASS = 'N' THEN CLASSN = 1; >IF JOBCLASS = 'P' THEN CLASSP = 1; >IF JOBCLASS = 'R' THEN CLASSR = 1; >IF JOBCLASS = 'T' THEN CLASST = 1; >IF JOBCLASS = 'U' THEN CLASSU = 1; >IF JOBCLASS = 'V' THEN CLASSV = 1; >IF JOBCLASS = 'Y' THEN CLASSY = 1; >TOTAL = 1; >OUTPUT; >END;


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