The script first initializes an XML library ('access') pointing to 'd:\test.xml', configured for MS Access format with schema metadata. Then, a DATA step creates a temporary dataset named 'test' in the WORK library, populating it with data from 'sashelp.retail' and adding an index on the 'year' and 'month' variables. Finally, PROC COPY is used to copy this 'test' dataset from WORK to the 'access' XML library, which has the effect of exporting it to the 'd:\test.xml' file. The session ends by releasing the 'access' library.
Data Analysis
Type : SASHELP
Data comes from the internal dataset 'sashelp.retail'. The XML file 'd:\test.xml' is the export destination.
1 Code Block
LIBNAME
Explanation : Defines the libname 'access' as an XML library, linking it to the file 'd:\test.xml'. The options 'xmltype=msaccess' and 'xmlmeta=schemadata' specify the XML format for compatibility with MS Access and the inclusion of schema metadata.
Copied!
libname access xml 'd:\test.xml'
xmltype=msaccess xmlmeta=schemadata;
1
LIBNAME access xml 'd:\test.xml'
2
xmltype=msaccess xmlmeta=schemadata;
3
2 Code Block
DATA STEP Data
Explanation : Creates a temporary dataset named 'test' in the WORK library. It is populated with data from the 'retail' dataset in the SASHELP library. An index is also created on the 'year' and 'month' columns to optimize access.
Copied!
data test(index=(year month)) ;
set sashelp.retail ;
run ;
1
2
DATA test(index=(year month)) ;
3
SET sashelp.retail ;
4
RUN ;
5
3 Code Block
PROC COPY
Explanation : Copies the 'test' dataset from the WORK library to the 'access' library (the XML file 'd:\test.xml'). The 'index=yes' option ensures that all indexes defined on the source dataset are also copied to the destination.
Copied!
proc copy in=work out=access index=yes ;
select test ;
run ;
1
2
PROC COPY in=work out=access index=yes ;
3
select test ;
4
RUN ;
5
4 Code Block
LIBNAME
Explanation : Releases the libname 'access', dissociating the logical name 'access' from the file 'd:\test.xml'.
Copied!
libname access ;
1
LIBNAME access ;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.