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 2003, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 14 Jan 2003 11:50:23 +0000
Reply-To:     ciro baldi <baldi@ISTAT.IT>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         ciro baldi <baldi@ISTAT.IT>
Organization: CASPUR - Inter-University Computing Consortium
Subject:      assigning values according to conditions set in a table
Content-Type: text/plain; charset=us-ascii

dear listers, i have to write a program that assign values to a numeric variable in a main dataset according to some conditions that are available in an external table (say another dataset). For example the main dataset is like: id size code1 code2 code3 a 15 15301 czda 1420 b 30 18700 qbrdsa 1800 .................................. ..................................

and the conditions dataset is like this code1 size code2 code3 x 15301 0-15 cz 1420 0.8 15301 0-15 qb 1420 0.7 15301 > 15 qb 1420 0.6 18700 0-20 qb 1800 0.9 18700 > 20 sa 1800 1.1 ..................................... the program i would like to write should be like: data main1; set main; if (code1='15301') and (0 < size <= 15) and (code2 contains(*) 'cz') and (code3='1420') then x=0.8; if (code1='15301') and (0 < size <= 15) and (code2 contains(*) 'qb') and (code3='1420') then x=0.7; if (code1='15301') and ( size > 15) and (code2 contains(*) 'qb') and (code3='1420') then x=0.6; if (code1='18700') and (0 < size <= 20) and (code2 contains(*) 'qb') and (code3='1800') then x=0.9; if (code1='18700') and (> 20) and (code2 contains(*) 'sa') and (code3='1800') then x=1.1; ....... run;

so the risulting dataset main1 should be: id size code1 code2 code3 x a 15 15301 czda 1420 0.8 b 30 18700 qbrdsa 1800 1.1 .................................. ..................................

i can try to standardize as much as possible the conditions table, but i will remain with the problem of how to translate it in a sas program.

(*) i do not know, if exist, which sas function works in this case.

any help, information, suggestions and so on would be gratly appreciated

ciro


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