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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.