BookmarkSubscribeRSS Feed
saslovethemost
Quartz | Level 8

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.

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Look up the data step commands MERGE and UPDATE.

 

Also, this is possible in PROC SQL.

--
Paige Miller
saslovethemost
Quartz | Level 8

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

Reeza
Super User
What are you trying to do?
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
PGStats
Opal | Level 21

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
Astounding
PROC Star

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 856 views
  • 0 likes
  • 5 in conversation