If you want to use it later you create it in a macro variable and reference it later with a &variableName
Let's assume:
- data set name is myDataset
- variable name is value
- Single observation/row in the data set
- Macro variable output name is myValue
*create fake data;
data myDataset;
date = mdy(7, 18, 2022);
format date ddmmyyn8.;
value = 15;
output;
run;
data _null_; *_null_ means SAS will not create a data set as output;
set myDataset; *indicate the input data set;
call symputx('myValue', value, 'g'); *create the variable with a global scope;
run;
Then to use it later, say filter all people under the age of myValue.
data below15;
set sashelp.class;
where age <= &myValue;
run;
Here is more references on Macro variables.
https://stats.oarc.ucla.edu/sas/seminars/sas-macros-introduction/
Generally speaking though, avoiding macros at the beginning is recommended. You should code without macros as much as possible. There are often other ways of doing things.