Hi,
This code is wrong and does not work:
myname= 'SMITH';
DATA lookup;
SET some_data_file;
KEEP lname and some other variables;
WHERE lname = myname;
RUN;
but it shows what I want to do.
I will have multiple reads data grabs and reads and rather than change the value for a variable (in this case lname) in multiple places (even though find and replace is nice!) I'd like to set it once globally outside the scope of the DATA statements (or even PROC statements) and then be able to use it later in those statements.
How is this done??
%let myname= "SMITH";
DATA lookup;
SET some_data_file;
KEEP lname and some other variables;
WHERE lname =&myname;
RUN;
Macro variables.
I've moved the quotes, but where you include them is up to you.
%let myname = SMITH;
DATA lookup;
SET some_data_file;
KEEP lname and some other variables;
WHERE lname = "&myname";
RUN;
%let myname= "SMITH";
DATA lookup;
SET some_data_file;
KEEP lname and some other variables;
WHERE lname =&myname;
RUN;
Outstanding!
On another note, since you plan on running this multiple times you can speed it up by moving KEEP:
data lookup;
set some_data_file (keep=lname and some other variables);
where lname= ...
run;
This will limit which variables get read in. The original program reads in all the variables, and then limits what gets output.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.