12-05-2013 07:45 AM
I would to determine if there is a record in a data set that contains a specific value for one of the variables in the data set. In other programming languages you can set a global variable (meaning it is available outside of the given function) to equal something when processing records indicates one of the records contains what you are looking for. You can use this variable in other programming steps.
In SAS, is there a way to do this?
12-05-2013 08:04 AM
12-05-2013 08:04 AM
12-05-2013 08:12 AM
Sounds to me like you want to set macro variables but as with a lot of things in SAS there are multiple approaches and Im not sure given the broad nature of the question what would be best in your situation.
In general you can use %let to set a macro variable that basically stores the text you want to use else where in the code:
%let macrovarname = stored value or code ;
then use the macro variable using ¯ovarname
%let where = id in (3, 4 , 5, 20 , 33) ;
create table limitedresults as
More specifics about what you are trying to do may help craft a better solution by the community.
12-05-2013 08:18 AM
Your example with a 'macro' variable does not use a macro though. Do you need to use a macro variable only in a marco?
12-05-2013 08:25 AM
Macro variables are available to use outside of a formal macro definition. Try the following code:
%let make = Acura;
where make = "&make";
You should get the dataset TEMP with 7 observations.
12-05-2013 08:53 AM
As others have indicated, creating a macro variable is the right way to go. You don't need to define a macro in order to create and use a macro variable. However ... if you plan to use that macro variable to determine which steps should run later in the program, you will probably need to define a macro. The reason is that macro language %IF / %THEN statements can appear only inside a macro definition.
Need further help from the community? Please ask a new question.