Hello team,
I have this code:
data storm_cat;
set pg1.storm_summary;
keep Name Basin MinPressure StartDate PressureGroup;
*add ELSE keyword and remove final condition;
if MinPressure=. then PressureGroup=.;
else if MinPressure<=920 then PressureGroup=1;
else PressureGroup=0;
run;
PressureGroup is created after the keep statement. How does keep statement knows about
PressureGroup?
Your response is greatly appreciated.
GN
@GN0001 wrote:
Hello team,
I have this code:
data storm_cat;
set pg1.storm_summary;
keep Name Basin MinPressure StartDate PressureGroup;
*add ELSE keyword and remove final condition;
if MinPressure=. then PressureGroup=.;
else if MinPressure<=920 then PressureGroup=1;
else PressureGroup=0;
run;
PressureGroup is created after the keep statement. How does keep statement knows about
PressureGroup?
Your response is greatly appreciated.
GN
There are statements that SAS refers to as "Declaritive".
The order of most of these does not matter though the position may look "odd" in some contexts, especially if you get in a particular coding habit. Exceptions are Data (start a data step) Cards/Cards4/Datalines/Datalines4 which precede in-line data at the end of a step, and the End which ends a DO or Select block. Length may go anywhere but could generate some warnings about variables that exist.
Declarative Statements ARRAY DATALINES4 Labels, Statement ATTRIB DROP LENGTH BY END RENAME CARDS FORMAT RETAIN CARDS4 INFORMAT WHERE DATA KEEP WINDOW DATALINES LABEL
@GN0001 wrote:
Hello team,
I have this code:
data storm_cat;
set pg1.storm_summary;
keep Name Basin MinPressure StartDate PressureGroup;
*add ELSE keyword and remove final condition;
if MinPressure=. then PressureGroup=.;
else if MinPressure<=920 then PressureGroup=1;
else PressureGroup=0;
run;
PressureGroup is created after the keep statement. How does keep statement knows about
PressureGroup?
Your response is greatly appreciated.
GN
There are statements that SAS refers to as "Declaritive".
The order of most of these does not matter though the position may look "odd" in some contexts, especially if you get in a particular coding habit. Exceptions are Data (start a data step) Cards/Cards4/Datalines/Datalines4 which precede in-line data at the end of a step, and the End which ends a DO or Select block. Length may go anywhere but could generate some warnings about variables that exist.
Declarative Statements ARRAY DATALINES4 Labels, Statement ATTRIB DROP LENGTH BY END RENAME CARDS FORMAT RETAIN CARDS4 INFORMAT WHERE DATA KEEP WINDOW DATALINES LABEL
The keep statement controls what goes to the output dataset(s). It has no effect on the presence of variables within the data step.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.
Find more tutorials on the SAS Users YouTube channel.