I am trying to use the following macro to name my data file but it is not working but not sure why. It gets stuck on "data temp_&yymm._seg&i". It seems to get stuck due to having 2 macro variables in the file name.
Could I get some help? Thank you.
Actually, there is a HUGE difference between: temp_&yymm._seg&i as a macro variable reference (with the dot[.] ) and temp_&yymm_seg&i without the dot [.] in the name.
Your code does NOT show the dot. I would suspect that you are getting messages something like this:
WARNING: Apparent symbolic reference YYMM_SEG not resolved.
Or something similar if you do NOT have a single dot that shows the macro processor where one macro variable ends and the rest of the string begins. If you need to have a dot in a resolved macro variable name, such as you needed to build a dataset name from 2 macro variables, then you use 2 dots -- one dot for the delimiter and the second dot as part of the resolved value, like this:
%let lib = perm;
%let myfile = cars;
proc print data=&lib.&myfile <---would be wrong
proc print data=&lib..&myfile <---would be correct
For more information about macro variable concatenation to build text strings from multiple macro variables, consult the macro documentation. In addition, this paper is a good introduction to macro processing concepts. http://www2.sas.com/proceedings/sugi28/056-28.pdf