BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hhchenfx
Barite | Level 11

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;

 

1 ACCEPTED SOLUTION
4 REPLIES 4
hhchenfx
Barite | Level 11

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;

 

art297
Opal | Level 21

I think you want to replace the semi-colon after 

%EXIT_EXIT_EXIT;

with a colon (i.e., : )

 

Art, CEO, AnalystFinder.com

 

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 10191 views
  • 4 likes
  • 3 in conversation