BookmarkSubscribeRSS Feed
kyesrao
Fluorite | Level 6

Hi,

On Z/OS Mainframe SAS, I was trying to find a way to create an xml file from the SAS dataset created by pulling DB2 data.

However, I was not successful. Please help.

 

Thanks,

kyesrao.

8 REPLIES 8
andreas_lds
Jade | Level 19

What have you tried so far? Which SAS version is available? Check out libname xml.

kyesrao
Fluorite | Level 6
Version9.4.
I did not where to start. Your email helped me where to start.
I will start researching further with your inputs libname xml.

Thank you.
Cynthia_sas
SAS Super FREQ

Hi:

  Here's a simple example using just 3 obs from SASHELP.CLASS:

make_xml_file_from_sas_data.png

 

  Here's the tip sheet on  using the LIBNAME XML engine: https://support.sas.com/rnd/base/xmlengine/XML94tipsheet.pdf

 

cynthia

kyesrao
Fluorite | Level 6
Hi Cynthia,
I think I am doing something wrong that I am not able to find out.
Here is what I have in my job.

PROC SQL;
CONNECT TO DB2 (SSID=SYDP);
%PUT &SQLXMSG;

CREATE TABLE CVDDATA AS
SELECT * FROM CONNECTION TO DB2
(SELECT CVD_EMPLOYEE_ID AS EMEID
,CVD_MEMBER_ID AS MBRID
,CVD_EDATE AS CVDEDT
,CVD_TDATE AS CVDTDT
FROM EIPRDADM.EITBAS_COVDETAIL
WHERE CURRENT_DATE BETWEEN CVD_EDATE AND CVD_TDATE
AND CVD_COVERAGE_CD LIKE 'H%'
AND CVD_EMPLOYEE_ID ='0000000192' );

%PUT &SQLXMSG;
DISCONNECT FROM DB2;
%PUT &SQLXMSG;

PROC PRINT DATA=CVDDATA;
TITLE '<=====CVDDATA=====>';
FORMAT CVDEDT YYMMDD10.;
FORMAT CVDTDT YYMMDD10.;

FILENAME OUT 'C:\Users\b869363\Desktop\CVDOUT.xml';
LIBNAME OUT XML92 XMLTYPE=XMLMAP
XMLMAP='C:\Users\b869363\Desktop\CVDexport.map';

DATA OUT.CVDOUT;
SET CVDDATA;

The PROC PRINT shows like this.
<=====CVDDATA=====>

Obs EMEID MBRID CVDEDT CVDTDT

1 0000000192 0000000412 2016-09-01 9999-12-31
2 0000000192 0000000192 2016-09-01 9999-12-31
3 0000000192 0000000758 2016-07-01 9999-12-31
******************************** BOTTOM OF DATA ***********

However, the next statement which is FILENAME is reported as error as shown
below. Please help.

27 FILENAME OUT 'C:\Users\b869363\Desktop\CVDOUT.xml';
ERROR: Invalid file, C:\USERS\B869363\DESKTOP\CVDOUT.XML.
ERROR: Error in the FILENAME statement.
27 !
28 LIBNAME OUT XML92 XMLTYPE=XMLMAP
29 XMLMAP='C:\Users\b869363\Desktop\CVDexport.map';

ERROR: Error in the LIBNAME statement.

Patrick
Opal | Level 21

@kyesrao

Your code runs on the server side which happens to be a Mainframe. A path like C:\Users\b869363\Desktop\CVDOUT.xml is certainly not valid on a Mainframe.

Cynthia_sas
SAS Super FREQ
If this job is going to run on the mainframe, you'll probably have to move your XML Map file up there, too. My recommendation, if this is not working for you, and you know that you are running SAS 9.2 or higher on your mainframe, then you might want to open a track with Technical Support for quicker help.

cynthia
kyesrao
Fluorite | Level 6

As Cynthia suggested, I did open a track and it helped me generate the XML document even without using an XML schema.

Instead of these 3 statements,

FILENAME OUT 'C:\Users\b869363\Desktop\CVDOUT.xml';
LIBNAME OUT XML92 XMLTYPE=XMLMAP
XMLMAP='C:\Users\b869363\Desktop\CVDexport.map';

 

I had to code this one line.

LIBNAME OUT XMLV2

where LIBNAME is the reserved word, XMLV2 is the engine name and OUT is the DDNAME assigned to the following dataset.

DD DSN=EI.BAS.TESTXML.D180310,DISP=(,CATLG),  
UNIT=SMSDA,SPACE=(CYL,(100,2),RLSE),       
DCB=(RECFM=VB,LRECL=80,BLKSIZE=0),RETPD=180

 

kyesrao
Fluorite | Level 6

Here is the final output.

<?xml version="1.0" ?>           
<TABLE>                          
   <CVDOUT>                      
      <EMEID>0000854192</EMEID>  
      <MBRID>0000319496</MBRID>  
      <CVDEDT>2016-09-01</CVDEDT>
      <CVDTDT>9999-12-31</CVDTDT>
   </CVDOUT>                     
   <CVDOUT>                      
      <EMEID>0000854192</EMEID>  
      <MBRID>0000854192</MBRID>  
      <CVDEDT>2016-09-01</CVDEDT>
      <CVDTDT>9999-12-31</CVDTDT>
   </CVDOUT>                     
   <CVDOUT>                      
      <EMEID>0000854192</EMEID>  
      <MBRID>0000867758</MBRID>  
      <CVDEDT>2016-07-01</CVDEDT>
      <CVDTDT>9999-12-31</CVDTDT>
   </CVDOUT>                     

</TABLE>

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 804 views
  • 2 likes
  • 4 in conversation