Hmmm, actually, I think it looks more like THIS if you map from the original files to the desired output.
It looks like the TEST1 data populates the first 3 columns for each row and the TEST2 data populates the last 3 columns for each row, but the variable names determine which row the value belongs to (determines the year).This is awkward because that means you have to restructure/rename the data for it to be usable. It's almost a transpose or maybe 2 transposes. It complicates things that the same variable names are used for different columns in the final output.
Cynthia
Hi Reeza,
After we run test data Test56 would have below columns with 0 and 1's and we do proc summary on those columns . I can rename the columns in the output data as well as in the report like CC_AOS .
SN_CCY1
SN_CCY2
SN_BBY1
SN_BBY2
SN_Pairy1
SN_Pairy2
PP_CC
PP_BB
SN_Pairy1Y2
DATA TEST56(KEEP=
SN_CCY1
SN_CCY2
SN_BBY1
SN_BBY2
SN_Pairy1
SN_Pairy2
PP_CC
PP_BB
SN_Pairy1Y2
);
SET XYZ END = EOF;
BY id ;
RETAIN CCY1 CCY2 BBY1 BBY1 ;
IF FIRST.id THEN
DO;
BBY1 = 'N';
BBY2 = 'N';
CCY1 = 'N';
CCY2 = 'N';
END;
IF CC GT 0 AND YEAR = 2014 THEN CCY1 = 'Y' ;
IF CC GT 0 AND YEAR = 2015 THEN CCY2 = 'Y' ;
IF BB GT 0 AND YEAR = 2014 THEN BBY1 = 'Y' ;
IF BB GT 0 AND YEAR = 2015 THEN BBY2 = 'Y' ;
IF LAST.id OR EOF THEN
DO;
SN_CCY1 = 0;
SN_CCY2 = 0;
PP_CC = 0;
SN_BBY1 = 0;
SN_BBY2 = 0;
PP_BB = 0;
SN_Pairy1 = 0;
SN_Pairy2 = 0;
SN_Pairy1Y2 = 0;
IF CCY1 = 'Y' THEN SN_CCY1 = 1;
IF CCY2 = 'Y' THEN SN_CCY2 = 1;
IF CCY1 = 'Y' AND CCY2 = 'Y' THEN PP_CC = 1;
IF BBY1 = 'Y' THEN SN_BBY1 = 1;
IF BBY2 = 'Y' THEN SN_BBY2 = 1;
IF BBY1 = 'Y' AND BBY2 = 'Y' THEN PP_BB = 1;
IF CCY1 = 'Y' OR BBY1 = 'Y' THEN SN_Pairy1 = 1;
IF CCY2 = 'Y' OR BBY2 = 'Y' THEN SN_Pairy2 = 1;
IF PP_CC = 1 or PP_BB = 1
THEN SN_Pairy1Y2 = 1;
OUTPUT TEST56;
END;
RUN;
PROC SUMMARY DATA = test56;
VAR SN_CCY1
SN_CCY2
PP_CC
SN_BBY1
SN_BBY2
PP_BB
SN_Pairy1
SN_Pairy2
SN_Pairy1Y2
;
OUTPUT OUT = TEST1
SUM= ;
RUN;
PROC PRINT DATA = TEST1;
RUN;
Hi Reeza,
Thanks for all your help . It is to identify unique id in 2014 , unique id in 2015 and unique id in both 2014 and 2015 .
Its Unique users in 2014 .
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.