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 (April 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 16 Apr 2008 14:09:17 -0400
Reply-To:     Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject:      Re: how to use results of a proc in rest of program and advice
              for newbie
Comments: To: beta_li@YAHOO.COM

On Wed, 16 Apr 2008 10:25:27 -0700, dolphinsmile <beta_li@YAHOO.COM> wrote:

>Hi, I'm a newbie at SAS and have not been able to refer to individual >resutls of a PROC in a later part of the code. >For example, if I use PROC MEANS and one of the outputs is the mean of >a variable called x, how can I assign this result to a variable that I >can refer to after the "run;" ends that PROC MEANS? >And a more general questions: My prior experience programming has been >in VBA and C (college course, not expert). If anyone has any advise >for the transition from a language like VBA to SAS, I'd really >appreciate it!!

hi,

it is usually the best to store the proc's output into a data set, so that you can use it later in data or proc steps. some proc's allow output statement to do just that (like proc means); some other proc's have an option OUT= to name the output data set (like procs freq or contents). Or you can direct the proc's output objects to the ods output destination, which creates dataset(s).

in sas, many, many, data management and analysis tasks are already implemented in various PROC's, in numerous data step statements/functions/(in)formats, and the like. so take advantage of them.

data steps are where you will "code" most. But the data step is half declarative and half procedural and each step is compiled-and-then-run. It does not necessarily execute one line at a time, top-to-bottom. There are much more things going on behind the scene by default. make sure you learn about it (hint: RTFM SAS Products > Base SAS > SAS Language Concepts > DATA Step Concepts)

data step arrays are not a bunch of blocks of memory pointed by index. It is rather an indirect way of referring a bunch of variables.

as a vba coder, you may feel as if sas is hostile to do-it-yourself coders (or my-classes-are-cleaner-than-yours coders) -- there has been no way of writing your own functions in the data step language until recently. :-) but this is about productivity than about not trusting users.

hang out at sas-l for a while, then you can discover that there are pretty creative users who find ways to be expressive even with this mostly pre-set coding environment. hth.

cheers, chang


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