Hi,
I am creating formats for look up so that i can avoid left joins which help in increasing performance.
For example based on the data i get i want to create formats
DATA TEST;
INPUT CODE $;
DATALINES;
NC
NY
AZ
;
RUN;
%MACRO FMT;
%GLOBAL CNT;
PROC SQL NOPRINT;
SELECT COUNT(*) INTO :CNT FROM TEST
WHERE CODE NE ' ' ;
QUIT;
%IF &CNT > 0 %THEN %DO;
PROC SQL NOPRINT;
CREATE TABLE SPECDESC AS
SELECT CODE AS START,DESC AS LABEL,'$DES' AS FMTNAME
FROM DESCR_TB
WHERE CODE IN (SELECT CODE FROM TEST WHERE CODE NE '' );
QUIT;
PROC FORMAT CNTLIN=SPECDESC;
RUN;
%END;
%MEND;
%FMT;
DATA TEST1;
SET TEST;
IF &CNT > 0 THEN DO;
DESCR=PUT(CODE,$DES.);
END;
ELSE DO;
DESCR=CODE;
END;
RUN;
I am getting an error when i am not having data in test
It is showing that $DES format cannot be found or load.
I want to create formats based on the data.I want to find a work around when there is no data.
How about after:
PROC FORMAT CNTLIN=SPECDESC;
RUN;
%END;
insert:
%ELSE %DO;
PROC FORMAT;
VALUE $DES;
RUN;
%END;
Tom
Or add another column to specify the format type.
SELECT CODE AS START,DESC AS LABEL,'DES' AS FMTNAME,'C' AS TYPE
Ksharp
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.