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

Hi Geeks,

 

I am trying to run SAS OPTGRAPH Procedure as to learn more about Travelling Salesman problem (for ShortestPath) using SAS 9.2 version but unfortunately I keep getting "ERROR: 22-322, Expecting an Integer Constant" where more details of this error is in the attached picture. 

 

I followed the same instructions in this SAS Support Forum .

 

The sample data includes two nodes (the starting point which is classified as "FROM" and the end point classified as "TO") in addition to the weight of this transaction coded as below:

 

STEP 1:  Loading the data

data LinkSetIn;input from $ to $ weight @@;datalines;A B 1.0 A C 1.0 A D 1.5 B C 2.0 B D 4.0B E 3.0 C D 3.0 C F 3.0 C H 4.0 D E 1.5D F 3.0 D G 4.0 E F 1.0 E G 1.0 F G 2.0F H 4.0 H I 3.0 I J 1.0 C J 5.0 F J 3.0F I 1.0 H J 1.0;

 

Step 2: Run PROC OPTGRAPH MACRO

proc optgraphloglevel = moderatedata_links = LinkSetInout_nodes = NodeSetOut;tspout = TSPTour;run;%put &_OPTGRAPH_;%put &_OPTGRAPH_TSP_;

 

and the error is: 

Capture.PNG

1 ACCEPTED SOLUTION
7 REPLIES 7
ballardw
Super User

There is no need to go through extra steps to make images of logs and paste them. Best is to copy directly from the log and then paste into a code window opened with either of  the forums {I} or "running man" icons.

 

The error about the expected integer constant means that the procedure is looking for just that: a number such as

loglevel=2

 

The "out of order" error often is associated with placing a semicolon before a Proc option. The ; would end the procedure statement so the option is not valid in the location of the code encountered.

RobPratt
SAS Super FREQ

The TSP statement was not added to PROC OPTGRAPH until version 12.3 (SAS 9.4):

http://support.sas.com/documentation/solutions/optgraph/index.html

 

You can also access the TSP algorithm via PROC OPTNET or PROC OPTMODEL (solve with network) in SAS/OR, or via PROC OPTNETWORK or the Network Optimization action set in SAS Optimization on SAS Viya.

 

 

WaelAburezeq
Obsidian | Level 7

Thanks for this useful reply but when I ran PROC OPTNET I keep getting "ERROR: Procedure Not Found", it seems that it is also supported from 9.3 (where I have 9.2) Right?

 

For PROC OPTMODEL , I followed the same instructions as in this SAS Support TSP:

 

data LinkSetIn;
   input from $ to $ weight @@;
   datalines;
A B 1.0   A C 1.0   A D 1.5   B C 2.0   B D 4.0
B E 3.0   C D 3.0   C F 3.0   C H 4.0   D E 1.5
D F 3.0   D G 4.0   E F 1.0   E G 1.0   F G 2.0
F H 4.0   H I 3.0   I J 1.0   C J 5.0   F J 3.0
F I 1.0   H J 1.0
;

proc optmodel;
   set<str,str> EDGES;
   set<str> NODES = union{<i,j> in EDGES} {i,j};
   num weight{EDGES};
   read data LinkSetIn into EDGES=[from to] weight;
   num tsp_order{NODES};
   set<str,str> TOUR;

   solve with NETWORK /
      loglevel = moderate
      links    = (weight=weight)
      tsp
      out      = (order=tsp_order tour=TOUR)
   ;

   put TOUR;
   print {<i,j> in TOUR} weight;
   print tsp_order;
   create data NodeSetOut from [node] tsp_order;
   create data TSPTour from [from to]=TOUR weight;
quit;

but I got the following error as well:

Capture2.PNG

 

RobPratt
SAS Super FREQ

PROC OPTNET was released in August 2012 with SAS/OR 12.1 (on SAS 9.3M1).

 

The SOLVE WITH NETWORK statement was added to PROC OPTMODEL in December 2013 with SAS/OR 13.1 (on SAS 9.4M1).

 

I would strongly recommend that you upgrade to the latest release (SAS/OR 14.3 on SAS 9.4M5) to take advantage of these features and to benefit from the significant performance improvements over the last several years.  Until then, you might be interested in the subtour formulation from this SAS/OR 9.22 example:

http://support.sas.com/documentation/cdl/en/ormpug/63352/HTML/default/viewer.htm#ormpug_milpsolver_s...

WaelAburezeq
Obsidian | Level 7

Thanks again for your reply,

 

I checked this article before, but the library at http://elib.zib.de/pub/Packages/mp-testdata/tsp/tsplib/tsplib.html is not found. This is where I should start.

 

WaelAburezeq
Obsidian | Level 7

The forum has more restricted roles to post a question. For the out of order, the code was retrieved from SAS support documentation. The problem might be related to SAS version 9.2 which TSP has been supported since 9.4

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1879 views
  • 0 likes
  • 3 in conversation