My problem is the "x" variable in the first row which is a global variable(hence the &) that is assigned a value dynamically prior to this data step when the script is run. But SAS does not accept that I place the variable directly in the datalines as above. It is deemed invalid data in the log. Can anyone help me on this one? I can only come up with one possible explanation. Earlier in the script I use the "call symput" routine in order to make "x" a global variable. As far as I can tell this routine converts any numeric data into character data meaning that I am trying to input character data datastep written above?
Hope someone can help me. Thanks.
This does not really seem like an ODS question, but more of a DATA step INFILE/INPUT statement question.
As you noted, the macro variable &x is NOT resolved in the input buffer, so when your INPUT statement tries to read it from the buffer, SAS sees non-numeric characters where it is expecting to see numeric characters. In fact, the documentation on the SAS Macro facility states that:
"You can define and use macro variables anywhere in SAS programs, except within data lines." Since &x is a macro variable reference you cannot "technically" use it within your data lines.
If all you need to do is change con2 to the value of &x for the "beta" row (when _n_ = 1), then this would work in your existing program (as you have presented the hypothetical data):
if firms = 'beta' and _n_ = 1 then do;
con2 = input("&x",8.0);
If &x is in the global symbol table when the DATA step program executes, then the value for &x will be translated from character to numeric by the INPUT function (different from the INPUT statement). You will still see a warning in the LOG that there was a problem trying to read &x as a number.
I worry a bit about your usage of the term "script" and your reference to using CALL SYMPUT to set the value of X. Generally, you use CALL SYMPUT within a DATA step program to set the value of a macro variable (in the global symbol table) from some value within a DATA step program at execution time. This implies to me, somehow that the value of the macro variable &x might be changing based on the value of some variable in some -other- DATA step program.