Refer a variable

Reply
Contributor
Posts: 25

Refer a variable

Hi

 

I would like to know all the possible ways to refer a varaible created in one data step to in an another datastep.

 

Thanks

Neal.

Trusted Advisor
Posts: 1,631

Re: Refer a variable

Look up the data step commands MERGE and UPDATE.

 

Also, this is possible in PROC SQL.

Contributor
Posts: 25

Re: Refer a variable

Sorry was not specific enough I think. How to use the value that is been created in one data step in another datastep.

Super User
Posts: 17,929

Re: Refer a variable

What are you trying to do?
Trusted Advisor
Posts: 1,631

Re: Refer a variable


saslovethemost wrote:

Sorry was not specific enough I think. How to use the value that is been created in one data step in another datastep.


I already answered this.

 

I said:

 

Look up the data step commands MERGE and UPDATE.

 

Also, this is possible in PROC SQL.

Respected Advisor
Posts: 4,659

Re: Refer a variable

[ Edited ]

There are two kinds of variables in SAS : dataset variables and macro variables.

 

  • Dataset variables reside within a dataset. You don't have access to them in another data step unless you refer to the dataset in a SET, MERGE, UPDATE or MODIFY statement.
  • Macro variables are handled by the SAS interpreter. They are simple name=string pairs that can be reused anywhere in a SAS session. The interpreter compiles program blocks ( DATA ... RUN; or PROC ... RUN; ) at a time. So if you give a value to a macro variable somewhere in a SAS program, you can reuse that value in another part of the program that will be compiled later.
PG
Super User
Posts: 5,096

Re: Refer a variable

I can think of at least 10 topics that would be more important to learn about in a DATA step:

 

_n_

variable lists

arrays

DO loops

first. and last.

MERGE

multiple SET statements

RETAIN

sum statement

setting lengths of character variables

 

To address your question, refer to the variable by the variable name.  Any other way isn't important until much later in your SAS education.  Spend your time wisely!

Ask a Question
Discussion stats
  • 6 replies
  • 342 views
  • 0 likes
  • 5 in conversation