BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
daradanye
Obsidian | Level 7

Hi,

 

Thanks a lot in advance!  I am running a proc netflow process to find the shortest path.  I have a problem when I try to keep macro variable _ORNETFL after running proc netflow process. _ORNETFL is generated by proc netflow process automatically.

 

The code I wrote is:

 

%macro model(aa=,bb=);

data temp;
set _null_;
run;

data spath;
set _null_;
run;


proc netflow
   shortpath
   sourcenode=&aa
   sinknode=&bb   
   ARCDATA=aircost
   arcout=spath;
   tail    origin;
   head    dest;
run;

%put &_ORNETFL;

data a; set _null_;run;

data a; set a;
value1=&_ORNETFL;
run;

%mend;

I call the macro as:

%model(aa=BAAHE, bb=DDFG)

The log file shows that:

NOTE: Number of nodes= 777 .
NOTE: Number of arcs= 5681 .
NOTE: Number of iterations performed (neglecting any constraints)= 837 .
NOTE: Of these, 836 were degenerate.
WARNING: Flow conservation cannot be achieved at the following nodes.
NOTE: The amounts after each node are the sum of flows through arcs directed
toward that node, plus that nodes supply, minus the nodes demand, minus
the sum of flows through arcs directed from the node.
DDIA -1
BAAHE 1
ERROR: The problem is infeasible. At least one nodal flow conservation
constraint cannot be satisfied.
WARNING: The solution value reported next is associated with a solution that is
not both feasible and optimal.
NOTE: Shortest path= 95.131944444 .
NOTE: The data set WORK.SPATH has 5681 observations and 14 variables.
ERROR_STATUS=OK OPT_STATUS=STAGE_1 SHORTEST_PATH=95.131944444444
SOLUTION=INFEASIBLE

NOTE: PROCEDURE NETFLOW used (Total process time):
real time 0.05 seconds
cpu time 0.02 seconds



NOTE: The data set WORK.A has 0 observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds



NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.A may be incomplete. When this step was stopped
there were 0 observations and 8 variables.
WARNING: Data set WORK.A was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds



NOTE: Line generated by the macro variable "_ORNETFL".
87 ERROR_STATUS=OK OPT_STATUS=STAGE_1 SHORTEST_PATH=95.131944444444
---------- -------------
22 22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **,
+, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT,
MAX, MIN, NE, NG, NL, NOTIN, OR, [, ^=, {, |, ||, ~=.

87 ! ERROR_STATUS=OK OPT_STATUS=STAGE_1 SHORTEST_PATH=95.131944444444
87 ! SOLUTION=INFEASIBLE
--------
22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +,
-, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT,
MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.

 

I guess it is something wrong with data step:

 

data a; set a;
value1=&_ORNETFL;
run;

I will appreciate it very much if someone could help me out.

 

Thanks again!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Without quotes around the value then the variable is treated as NUMERIC and the text held in the macro variable is obviously not numeric.

 

data a1;

   set a;
   value1= "&_ORNETFL";
run;

 

might help. If the variable VALUE1 exists in data set a and is numeric you will continue to get errors. If the variable Value1 exists and is character it might not be long enough to hold the complete text.

 

Note that frequent use of the structure;

Data a;

   set a;

 

WILL cause problems with corrupted data sets, missing values or variables or other problems hard to debug, especially when buried in a macro. Since you are basically clearing set A with the previous data a; set _null_;

perhaps just

 

data a;

   value1= "&_ORNETFL";
run;

 

View solution in original post

2 REPLIES 2
ballardw
Super User

Without quotes around the value then the variable is treated as NUMERIC and the text held in the macro variable is obviously not numeric.

 

data a1;

   set a;
   value1= "&_ORNETFL";
run;

 

might help. If the variable VALUE1 exists in data set a and is numeric you will continue to get errors. If the variable Value1 exists and is character it might not be long enough to hold the complete text.

 

Note that frequent use of the structure;

Data a;

   set a;

 

WILL cause problems with corrupted data sets, missing values or variables or other problems hard to debug, especially when buried in a macro. Since you are basically clearing set A with the previous data a; set _null_;

perhaps just

 

data a;

   value1= "&_ORNETFL";
run;

 

s_lassen
Meteorite | Level 14

I see two problems with you code.

 

One is the construction "data a;set _null_;run;" which creates a completely empty table (no obs, no vars - who taught you that? you should ask for your money back!). When you follow that with "data a;set a;...." then the code following "set a;" will not get executed - the execution stops after trying to read an obs from A and finding none. So you will get another table with no obs (but maybe some variables, if the code that follows declares some).

 

The other problem is that the _ORNETFL macro variable does not contain a numeric value, so if you want to assign it in a data step, you must quote it. Try this:

data a;
  value1="&_ORNETFL";
run;

That should at least store the value in the table A (which will now have one obs and one variable).

 

I assume you are doing this because you cannot access the _ORNETFL macro variable outside your macro, as it probably ends up getting declared %LOCAL to the macro, unless otherwise defined. If you want to access it outside the macro, you could also put a "%GLOBAL _ORNETFL;" statement in the top of your macro, or you could define it before calling the macro. Meaning that you could also put a "%LOCAL _ORNETFL;" statement in a calling macro (if there is one). Or simply define it in the global environment before calling the macro, e.g.:

%let _ORNETFL=;
%model(aa=BAAHE, bb=DDFG);

That way, it will stay blank if your macro call for some reason fails.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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