BookmarkSubscribeRSS Feed
KevinC_
Fluorite | Level 6
Hello,

I have 3 sas datasets : A,B, & C.
I want to merge A and B to create D. While in D, i would like to check the value of a variable from C.

DATA D;
MERGE A (IN=IN_A)
B (IN=IN_B);
BY EID;

IF IN_A AND IN_B THEN DO;
IF START_SW = " " THEN
CNT = CNT + 1;
*do more*

The If statement is not reconizing the variable START_SW, which is defined in Data C. How do I pass Start_sw to dataset D?

Thanks for any input!!
Kevin
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You would get most effective feedback by sending the diagnostic output from your SASLOG to include a PUTLOG _ALL_; command revealing all variable values. Any other feedback is a virtual crap-shoot, especially given that we don't know what your input WORK.A and WORK.B variable values contains with each DATA step pass.

Scott Barry
SBBWorks, Inc.
KevinC_
Fluorite | Level 6
thnx for your reply sbb.
I used PUTLOG _all_ to see the values of all.

the value of the variable I need is blank.
Let me ask a basic/stupid question: Can you pass a variable from one dataset X to another dataset Y without reading X?

If the answer is NO, then that's the problem I m facing.
I am merging 2 datasets (A & B) to create C. While I m in C, I need to access the variable from X. X contains only on row of data. If I use set to read X it would screw up my merge. Because the 2 files I am merging (A & B) contain multiple rows. The merge would stop after reading just one row. I hope I am explaining my problem clearly.

help please! 🙂
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
From your recent post, you gave some indication that there is only one row and variable/column you wish to pass to another DATA step. So, yes, you can use CALL SYMPUT in "data step #1" to generate a SAS macro variable.

And in "data step #2", you can use a RETAIN statement to access the macro variable, assigning a SAS data variable / column value, referencing the macro variable using double-quote marks in the RETAIN statement.

Scott Barry
SBBWorks, Inc.
KevinC_
Fluorite | Level 6
sbb, your suggestion worked !!!
Thank you !!!!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 4690 views
  • 0 likes
  • 2 in conversation