DATA Step, Macro, Functions and more

SAS Put Question

Reply
Regular Contributor
Posts: 173

SAS Put Question

Hello,

I am merging SAS dataset A with SAS dataset C by the variable SP1. A comes from an input file. C comes from the result of a query. I want to write SP1 from A and SP2 from C to the merged SAS dataset D. However, SP2 from C is blank when it's written out. I checked the result of the query and SP2 is not blank. Can anyone tell me what i m doing wrong? Here is what i have:

DATA A;
INFILE IN1;
INPUT @01 SP1 $CHAR10.
@11 SPCD1 $CHAR03.;
proc sort, by sp1;


PROC DB2EXT OUT = C UNIQUE;
SELECT A.ENTITYID AS SP1,
B.ENTITYID AS SP2
FROM ADUADS01.ADVTB912 A,
ADUADS01.ADVTB912 B,
WHERE A.ENTITYID = B.ENTITYID
FOR READ ONLY;
RUN;
PROC SORT; BY SP1;

DATA D;
MERGE A (IN=IN_A)
C (IN=IN_C);
BY SP1;
IF IN_A AND IN_C THEN DO;
PUT @1 SP1
@11 SP2;
END;


Thank you so much for your help!!!
Kevin
Regular Contributor
Posts: 173

Re: SAS Put Question

I guess the question could have been "how do i write a variable to a temporary SAS dataset?"

I could write it to an output file. But That's not really what I need. I m just running a series of merges. That's why I am using temporary sas datasets.

Thanks in advance for any input !!
Super Contributor
Super Contributor
Posts: 3,174

Re: SAS Put Question

Need to see some SASLOG session output with PUTLOG _ALL_; commands in order to understand your data conditions -- you also may find this debugging technique revealing as well. Also, you should confirm that SP1 is consistent in both input files, specifically, if a "formatted value" is being displayed for diagnosis, you may find that the "SAS internal value" shows that the two sources are not equal. Lastly, using the PUTLOG _ALL_; command will show the IN= variable values from your MERGE operation -- info that could be very revealing for your own diagnosis.


Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 2 replies
  • 109 views
  • 0 likes
  • 2 in conversation