Reading data from a database (MS Access) with sets as fields

Hi

We are looking to shift the dataset from MS Excel into a database
(Access, but we could shift to a different dbase).

Currently we have the Excel tables set up in a specific way, and use
gdxxrw to read the data in. One nice feature of this is we can mix
the sets across the row and column headings, and instruct the gdxxrw
how to read these in.

My question is whether there is a way to read this data in easily from
the database if the data is stored in similar form. From my reading
of the documentation it cannot, but I just want to check.


As a simple example for demo purposes will hopefully explain:

set p person /
andyC
sally /;
set sex sex /
male
female/;
set profile “profile detail of this person”
/ age
height
weight
phoneNumber /;

parameter person_profile(p,sex,profile);

In excel we can enter the data with the person down the rows, and
profile as the column headings, and when we read in via Excel we can
let gdxxrw know that sets p and sex are down the rows, and the profile
headings are across the columns.

eg
p sex age height weight phoneNumber
andyC male 15 170 65 123
sally female 20 180 75 456
etc

During the gdxxrw read we set RDIM=2 and CDIM=1, and it reads it in
perfectly.


Lets say that in the database the table is set up in a similar
layout. So the table structure would look something like the
following in design view (and would appear identical to the above
Excel output shown above when shown with data in it):

p text
sex text
age integer
height double
weight double
phoneNumber integer


Is there a way to instruct the read of the data into GAMS in a way
that it will know the first two columns are sets and the remaining
column headings is the remaining set (ie similar to rdim=2 and cdim=1
of gdxxrw).


I do know it can read it if it is in the form:

andyC Male Age 30
andyC Male Weight 65
etc

but we are wondering if we can avoid going for that form of table
structure, and keep it more like the original Excel layout.


All help appreciated

Cheers
AndyC

\

AC
You can use sql2gms feature to import data from databases into Gams. The restriction is that the database must have an ODBC driver. Many commercial or free databases has Odbc drivers, such as Oracle, MySql, Access, and so on. Also the communication between Excel and Gams can also be done by this feature.
Take a look at the library Gams data utility models and search for Odbc. I’ve been using this a while and I’m pretty satisfied with the results.
Regards

2011/6/15 AC

Hi

We are looking to shift the dataset from MS Excel into a database
(Access, but we could shift to a different dbase).

Currently we have the Excel tables set up in a specific way, and use
gdxxrw to read the data in. One nice feature of this is we can mix
the sets across the row and column headings, and instruct the gdxxrw
how to read these in.

My question is whether there is a way to read this data in easily from
the database if the data is stored in similar form. From my reading
of the documentation it cannot, but I just want to check.


As a simple example for demo purposes will hopefully explain:

set p person /
andyC
sally /;
set sex sex /
male
female/;
set profile “profile detail of this person”
/ age
height
weight
phoneNumber /;

parameter person_profile(p,sex,profile);

In excel we can enter the data with the person down the rows, and
profile as the column headings, and when we read in via Excel we can
let gdxxrw know that sets p and sex are down the rows, and the profile
headings are across the columns.

eg
p sex age height weight phoneNumber
andyC male 15 170 65 123
sally female 20 180 75 456
etc

During the gdxxrw read we set RDIM=2 and CDIM=1, and it reads it in
perfectly.


Lets say that in the database the table is set up in a similar
layout. So the table structure would look something like the
following in design view (and would appear identical to the above
Excel output shown above when shown with data in it):

p text
sex text
age integer
height double
weight double
phoneNumber integer


Is there a way to instruct the read of the data into GAMS in a way
that it will know the first two columns are sets and the remaining
column headings is the remaining set (ie similar to rdim=2 and cdim=1
of gdxxrw).


I do know it can read it if it is in the form:

andyC Male Age 30
andyC Male Weight 65
etc

but we are wondering if we can avoid going for that form of table
structure, and keep it more like the original Excel layout.


All help appreciated

Cheers
AndyC


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Edson Valle
edsoncv@gmail.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.