DATA Step, Macro, Functions and more

Why I'm Getting "Apparent symbolic reference "Variable" not resolved" Warning Message?

Accepted Solution Solved
Reply
Super Contributor
Posts: 395
Accepted Solution

Why I'm Getting "Apparent symbolic reference "Variable" not resolved" Warning Message?

Hello everyone,

 

I have a sample code as below, If I execute the first Data Step and Proc Sql, it works succesfully. However, If I take the conditions out in my second Data Step, macro variable still includes the "SET3" and "SET5" values. In my third Data Step and Proc Sql, I get a warning message because it doesn't includes the "SET3" and "SET5".

 

My first question is that, why it still includes "SET3" and "SET5" while the Data Set doesn't include these values?

Second, How can I prevent the getting the WARNING ->Apparent symbolic reference "Variable" not resolved"?

 

Thank you,

 

Data Datasets;
Length DataSetName $ 50 DataSetLabel $ 50 DataSetSuffix $ 50;
Infile Cards;
Input DataSetName DataSetLabel DataSetSuffix;
Cards;
Dataset1 FirstOne Set1
DataSet2 SecondOne Set2
DataSet3 ThirdOne Set3
DataSet4 FourthOne Set4
DataSet5 FifthOne Set5
;
Run;
Proc Sql NoPrint; 
Select DataSetSuffix Into:MacroVariable Separated By " "
From Datasets
Where Upcase(DataSetSuffix)="SET3" Or Upcase(DataSetSuffix)="SET5";
Quit;
%Put MacroVariable values are -> &MacroVariable.;
/* ******************** */
/*If I take these suffixes out from my data set they are still coming, why is the reason*/
Data Datasets;
Length DataSetName $ 50 DataSetLabel $ 50 DataSetSuffix $ 50;
Infile Cards;
Input DataSetName DataSetLabel DataSetSuffix;
Cards;
Dataset1 FirstOne Set1
DataSet2 SecondOne Set2
DataSet4 FourthOne Set4
;
Run;
Proc Sql NoPrint; 
Select DataSetSuffix Into:MacroVariable Separated By " "
From Datasets
Where Upcase(DataSetSuffix)="SET3" Or Upcase(DataSetSuffix)="SET5";
Quit;
%Put MacroVariable values are -> &MacroVariable.;
/* ******************** */
/*However,If I close the session and re-open the project and re-run the program and I am getting following "WARNING"->
WARNING: Apparent symbolic reference MACROVARIABLE2 not resolved. What is the reason for?*/
Data Datasets2;
Length DataSetName $ 50 DataSetLabel $ 50 DataSetSuffix $ 50;
Infile Cards;
Input DataSetName DataSetLabel DataSetSuffix;
Cards;
Dataset1 FirstOne Set1
DataSet2 SecondOne Set2
DataSet4 FourthOne Set4
;
Run;
Proc Sql NoPrint; 
Select DataSetSuffix Into:MacroVariable2 Separated By " "
From Datasets2
Where Upcase(DataSetSuffix)="SET3" Or Upcase(DataSetSuffix)="SET5";
Quit;
%Put MacroVariable values are -> &MacroVariable2.;

Accepted Solutions
Solution
‎07-31-2016 08:53 AM
Super User
Posts: 19,789

Re: Why I'm Getting "Apparent symbolic reference "Variable" not resolved" Warnin

In your last SQL query the conditions are not met so the macro variable is not created

Therfore it cannot be resolved. If you want it t exist even if the query is null create it as empty before the procedure. 

 

%let macrovariable2=;

View solution in original post


All Replies
Solution
‎07-31-2016 08:53 AM
Super User
Posts: 19,789

Re: Why I'm Getting "Apparent symbolic reference "Variable" not resolved" Warnin

In your last SQL query the conditions are not met so the macro variable is not created

Therfore it cannot be resolved. If you want it t exist even if the query is null create it as empty before the procedure. 

 

%let macrovariable2=;

Super Contributor
Posts: 298

Re: Why I'm Getting "Apparent symbolic reference "Variable" not resolved" Warnin

After first SQL query, the macro variable is generated. After the second SQL query, no rows were seletced and hence the old macro variable is not revised by the query. The macro variable which is in memory somewhere is still intact.

 

After ending the session and re-running your second query has no rows selected and hence the Macrovariable is not created. You want print it to see. There is no such variable in memory and that is the reason for getting the WARNING.

 

Hope this is useful to you.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 309 views
  • 2 likes
  • 3 in conversation