I've written two pieces of macro procedures. First macro is to generalize of retrieving a data from a dataset. First parameter is the data to be looked up in the dataset,and the second is the dataset name. I've created a local macro variable to initialize the look-up data to that variable.
So in the second procedure, i am trying to get the look-up data in the dataset and try tp print it to the log.
But i am proably doing something wrong. Could you please help me.
my aim is to open a dataset, assign variable to a macro variable in the dataset and close it and then finally i have a generalized function which i write the name of the dataset and the column name and retieve the data from the that dataset. thats it. I hope it is clear.
This my second attempt to understand what you need. The code below creates a dataset _a that contains the observation from input dataset for name="can". Is this what you need? or you need only ID for "can"?
%if &dsid NE 0 %then %do;
%else %put Error in &data;
Notice then name change of the positional parameter in SPR's code. But I am worried about your statement of the problem. We are a bit confused because macro variables are not, in any way, assigned to data sets. You do not need to open a data set to create a macro variable. Macro variables are held in memory for the duration of the SAS job or session. The values of macro variables can be used in the process of data set variable creation and assignment, but that is a very different process than the one you have started here.