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

I want to format my data based on a prompt value within Enterprise Guide.

e.g. if prompt_value = "A" define lead_time_format as follows:

 

proc format;
value lead_time_format
LOW-<0 = "After Arrival"
0 = "Day of Arrival"
1 = '1 day prior to Arrival';
run;

 

but otherwise (i.e. if prompt_value NE "B") define lead_time_format as follows:

proc format;
value lead_time_format
LOW-<0 = "After Departure"
0 = "Day of Departure"
1 = '1 day prior to Departure';
run;

 

I'm not sure how to go about this and so any suggestions would be appreciated..

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

@mduarte, I might just set it up like this:

%LET  Flight_Type	=	Arrival;

proc format;
value lead_time_format
LOW-<0 = "After &Flight_Type"
0 = "Day of &Flight_Type"
1 = "1 day prior to &Flight_Type";
run;
 
DATA _NULL_;

	Status1	=	-1;
	Status2	=	 0;
	Status3	=	 1;
	
	FORMAT	Status1 lead_time_format.;
	FORMAT	Status2 lead_time_format.;
	FORMAT	Status3 lead_time_format.;
		
	PUT  "NOTE:  -1 yields "  Status1;
	PUT  "NOTE-   0 yields "  Status2;
	PUT  "NOTE-   1 yields "  Status3;
	
RUN;

I'm using a %LET statement, but you would use a SAS EG prompt.  Notice also that I changed your last line from single quotes to double.  You need to use double quotes with macro variables.

 

Here's the log.

NOTE:  -1 yields After Arrival
         0 yields Day of Arrival
         1 yields 1 day prior to Arrival

Changing the macro variable to "Departure" yields:

NOTE:  -1 yields After Departure
         0 yields Day of Departure
         1 yields 1 day prior to Departure

 

Jim

View solution in original post

3 REPLIES 3
jimbarbour
Meteorite | Level 14

@mduarte, I might just set it up like this:

%LET  Flight_Type	=	Arrival;

proc format;
value lead_time_format
LOW-<0 = "After &Flight_Type"
0 = "Day of &Flight_Type"
1 = "1 day prior to &Flight_Type";
run;
 
DATA _NULL_;

	Status1	=	-1;
	Status2	=	 0;
	Status3	=	 1;
	
	FORMAT	Status1 lead_time_format.;
	FORMAT	Status2 lead_time_format.;
	FORMAT	Status3 lead_time_format.;
		
	PUT  "NOTE:  -1 yields "  Status1;
	PUT  "NOTE-   0 yields "  Status2;
	PUT  "NOTE-   1 yields "  Status3;
	
RUN;

I'm using a %LET statement, but you would use a SAS EG prompt.  Notice also that I changed your last line from single quotes to double.  You need to use double quotes with macro variables.

 

Here's the log.

NOTE:  -1 yields After Arrival
         0 yields Day of Arrival
         1 yields 1 day prior to Arrival

Changing the macro variable to "Departure" yields:

NOTE:  -1 yields After Departure
         0 yields Day of Departure
         1 yields 1 day prior to Departure

 

Jim

mduarte
Quartz | Level 8

Thanks @jimbarbour.  A further complication was that I was setting flight_type dependent on the EG prompt value and flight_type didn't have global scope.  So I had to do first:

%macro setVariableValues;
%global flight_type;
%if &category = FLIGHT WITH ARRIVALS %then 
%let flight_type= "Arrival";
%else %let flight_type= "Departure";
%mend setVariableValues;

%setVariableValues;

The other error I had was having quotation marks around FLIGHT WITH ARRIVALS, i.e. I had this value first enclosed in "" then '' and then by trial and error with no quotes, which thankfully finally worked.

 

jimbarbour
Meteorite | Level 14

Excellent.  Glad it worked.

 

Jim

 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 955 views
  • 1 like
  • 2 in conversation