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 (September 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 24 Sep 2005 04:20:04 -0700
Reply-To:     pa pa <ctll04@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         pa pa <ctll04@YAHOO.COM>
Subject:      Converting pseudo code into macro
Content-Type: text/plain; charset=iso-8859-1

Hi there, I am new to macros. I can write some SAS normal code but not macros. They seem an advanced topic. I am learning macros and would like to write something as the following pseudo code:

// This function compare all the values/rows in the first column of a dataset with a number. // If they are the same, the row will be encoded to be 1, otherwise, 0.

function EncodeTheClass(dataset, number) { for each row of the dataset { If( dataset.FirstColumn = number) { that row = 1 } else { that row = 0 } } }

Could someone please help me to turn this into a macro so that I can reuse it many times? Also how to call it in a sas code?

And finally, how can I know PROGRAMATICALLY how many 1s in the resultant/encoded column. I know that we can use PROC FREQ, but that is me, human can read the output. If I then want to input that value into another macro, I dont want to MANUALLY input. In oanother word, how a macro/sas code can actually get the frequency of a colum, i.e. I am looking for something like: "Frequency(column.values['1'])" -> get frequency of a specific value in a column.

Thanks Have a nice weekend Patrick Tran

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com


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