DATA Step, Macro, Functions and more

How to code for a prompt that is numeric that if left blank, the select will grab ALL observations.

Reply
Frequent Contributor
Posts: 82

How to code for a prompt that is numeric that if left blank, the select will grab ALL observations.

I am creating a stored process that will have 5 different prompts defined. All are character except for one, ‘DISTRICT’.   The user wants to be able to leave the ‘DISTRICT’ column blank and return all the observations, no matter what the numeric value of DISTRICT is.

 

I defined the prompt as a numeric type in SMC but cannot figure out how to handle it in the code/select statement.  Basically, it is like a wildcard on a character type column but on a numeric column.

 

This is one of my character type prompts. No matter what value is entered, a '%' for wildcard is added.

call symput("NEW_REGION_CD","'"||"&REGION_CD"||"%'");

 

Can't figure out how to do this same thing for prompt that is numeric.

 

Any assistance would be appreciated!!!

Super User
Posts: 19,769

Re: How to code for a prompt that is numeric that if left blank, the select will grab ALL observati

Posted in reply to ncsthbell

 

There isn't a wild card for numbers though.

 

You'd have to provide an example of how this would be used in the queries for us to offer suggestions.

Frequent Contributor
Posts: 82

Re: How to code for a prompt that is numeric that if left blank, the select will grab ALL observati

Sorry, here is a short example of my code.  The first statement on the 'where; clause is the numeric 'DISTRICT' column.  All others are character and work.

PROC SQL;
CREATE TABLE WORK.DATA_SELECTED AS 
	(SELECT 
		t1.DISTRICT,
		t1.OFFICE_NAME,
		t1.OFFICE_LOCATION
t1.OFFICE_MANAGER
		t1.NBR_EMPLOYEES,
		t1.COUNTY_NAME, 
		t1.ADDR_LINE_1, 
		t1.ADDR_LINE_1, 
		t1.CITY, 
		t1.STATE, 
		t1.ZIP
	    FROM  mylib.t1 DISTRIC_INFO
	    WHERE t1.District = &NEW_district
and t1.Office_Name LIKE &NEW_OFFICE_NAME
and t1.State = &NEW_STATE
and t1.County_Name = &NEW_COUNTY
and t1.City = &NEW_CITY
and t1.Zip = &NEW_ZIP );
QUIT;
Ask a Question
Discussion stats
  • 2 replies
  • 200 views
  • 0 likes
  • 2 in conversation