Hi Everyone,
I want to end an iteration and move to a new iteration when sample size is less than 5.
Can you please help me with that?
Thank you and have a nice weekend.
HHCFX
%MACRO test;
%do i=1 %to 100;
%do J=1 %to 100;
LOT OF ANALYSIS;
PROC SQL; SELECT COUNT(*) INTO: SAMPLE_SIZE FROM HAVE;QUIT;
%IF &SAMPLE_SIZE<5 %THEN END THE INNER-LOOP (J)
LOT OF ANALYSIS;
%end;
%end;
%MEND;
KEY
%MACRO test;
%do i=1 %to %sysfunc(countw(&rr_list));
%do J=1 %to %sysfunc(countw(&sl_list));
LOT OF ANALYSIS;
PROC SQL; SELECT COUNT(*) INTO: SAMPLE_SIZE FROM HAVE;QUIT;
%IF &SAMPLE_SIZE<5 %THEN %GOTO EXIT_EXIT_EXIT;
LOT OF ANALYSIS;
%EXIT_EXIT_EXIT;
%end;
%end;
%MEND;
you can use the %GOTO Macro Statement
you can use the %GOTO Macro Statement
Thank you.
So it will be like that, right?
%MACRO test;
%do i=1 %to %sysfunc(countw(&rr_list));
%do J=1 %to %sysfunc(countw(&sl_list));
LOT OF ANALYSIS;
PROC SQL; SELECT COUNT(*) INTO: SAMPLE_SIZE FROM HAVE;QUIT;
%IF &SAMPLE_SIZE<5 %THEN %GOTO EXIT_EXIT_EXIT;
LOT OF ANALYSIS;
%EXIT_EXIT_EXIT:
%end;
%end;
%MEND;
I think you want to replace the semi-colon after
%EXIT_EXIT_EXIT;
with a colon (i.e., : )
Art, CEO, AnalystFinder.com
Looks right.
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.
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.