BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9
Hello, i'm running a stored process which includes the following code: First i look in which of the three tables my col_ins_id is situated in. Afterwards i use the variables in a macro. This works nice but now i want to gain some time.

For example if I Find my ID in the first table, i don't want to count the other 2?
For example if I Find my ID in the second table, i don't want to count the third..

Greets

proc sql noprint;
select count(*) into:NumberEdcCd from RF300L3.edc_cd where col_ins_id = "&sel_col_ins_id";quit;
%put &NumberEdcCd;

proc sql noprint; select count(*) into:NumberEdcThick from RF300L3.edc_thick where col_ins_id = "&sel_col_ins_id";quit;
%put &NumberEdcThick;

proc sql noprint; select count(*) into:NumberEdcTxrF from RF300L3.edc_txrf where col_ins_id = "&sel_col_ins_id";quit;
%put &NumberEdcTxrF;



%macro getData;
%if &NumberEdcCd > 0 %then %do;
data out_table;
set RF300L3.edc_cd;
where col_ins_id = "&sel_col_ins_id";
run;
%end;
%else %if &NumberEdcThick > 0 %then %do;
data out_table;
set RF300L3.edc_thick;
where col_ins_id = "&sel_col_ins_id";
run;
%end;
%else %if &NumberEdcTxrF > 0 %then %do;
data out_table;
set RF300L3.edc_txrf;
where col_ins_id = "&sel_col_ins_id";
run;
%end;
%else %extract_edc_full(pInProcess WaferId User_id State Slot ROW_ID ProcessRecipe ProcessPlan PmProcedure MeasRecipe
MeasKey MainTool LotId LimitsKey InspectionTool Facility DuploWaferId Datim CustomKey
ChecklistActivityId CSIM_TIMESTAMP COL_INS_ID, out_table);
%mend;
%getData;
2 REPLIES 2
PatrickG
SAS Employee
Not sure what you're asking here....???
ballardw
Super User
I think you want to move the SQL bit into the GETDATA macro.

%macro getdata;

proc sql noprint;
select count(*) into:NumberEdcCd from RF300L3.edc_cd where col_ins_id = "&sel_col_ins_id";quit;
%if &NumberEdcCd = 0 %then %do:

proc sql noprint; select count(*) into:NumberEdcThick from RF300L3.edc_thick where col_ins_id = "&sel_col_ins_id";quit;

%if &NumberEdcThick >0 %then %do;

proc sql noprint; select count(*) into:NumberEdcTxrF from RF300L3.edc_txrf where col_ins_id = "&sel_col_ins_id";quit;
%end;/*NumberEdcThick*/
%end;/*NumberEdcCd */

/* rest of code*/

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 696 views
  • 0 likes
  • 3 in conversation