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..
@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, 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
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.
Excellent. Glad it worked.
Jim
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.