I’m generating a table in SAS and exporting it to a Microsoft Access database (mdb). Right now, I do this by connecting to the database as a library:
libname plus "C:\...\plus.mdb";
data plus.groupings;
set groupings;
run;
However, SAS doesn’t export the variable formats to the database, so I end up with numeric values in a table that I want to be human-readable. I’ve tried proc sql with the same effect. What can I do to get the formatted data into Access?
What I’ve tried so far:
Plain libname to mdb, data step (as above)
Plain libname to mdb, proc sql create table
OLE DB libname (as in Rob’s reference), data step
OLE DB libname, proc sql create table
From SAS support: if you create a SQL view using put() to define the variables, you can then export the view to the database and maintain the formatted values. Example:
I wasn’t able to just create the view directly in Access – it’s not entirely clear to me that Jet supports views in a way that SAS understands, so maybe that’s the issue. At any rate, the above does the trick for the limited number of variables I need to export. I can imagine automating the writing of such queries with a funky macro working on the output of proc contents, but I’m terribly grateful I don’t have to do that…