We need to extract data from z/os mainframe. We are able to download the datasets. However, data looks unreadable.
Here is the code we are using
%let PROD_UX=ram189prd.gwd.grpinf.net 5668;
%let MF=PROD_UX;
signon &MF. user="abcd" password="welcome2sas";
libname rwork slibref=work server=PROD_UX;
rsubmit &MF.;
data test2x /*view=test2x*/;
infile "PZLN.VMO00.POL1501" dsd;
input @1 KEY $8.
@9 STATUS1 $1.
@10 STATUS2 $1.
@19 RECTIME $8.
@27 CKEY $13.
@40 RECADTE $8.
@48 RECATME $8.
@56 CERTRTRN $1.
@57 MEDDIABC $1.
;
run;
endrsubmit;
Dataset is generated , however it looks like this
����
|
R
|
�
|
��� ���
|
M240N24021201
|
�N������
|
������
|
�
|
� ����
|
Q
|
A
|
13:08:17
|
M240N24021201
|
|
|
Y
|
� ����
|
A
|
M
|
13:08:17
|
M240N24021201
|
|
|
N
|
� ����
|
Q
|
A
|
13:08:17
|
M240N24021201
|
��*D50
|
00000000
|
0
|
� ����
|
R
|
�
|
��� ���
|
K620S36102402
|
�N������
|
������
|
�
|
� ����
|
P
|
A
|
09:14:34
|
K620S36102402
|
|
|
N
|
� ����
|
A
|
M
|
09:14:34
|
K620S36102402
|
|
|
N
|
� ����
|
A
|
M
|
09:14:34
|
K620S36102402
|
|
|
N
|
Here is Proc contents output
Data Set Name | RWORK.TEST2X | Observations | 304317 |
---|---|---|---|
Member Type | DATA | Variables | 9 |
Engine | REMOTE9 | Indexes | 0 |
Created | 02/04/2025 04:57:48 | Observation Length | 49 |
Last Modified | 02/04/2025 04:57:48 | Deleted Observations | 0 |
Protection | Compressed | NO | |
Data Set Type | Sorted | NO | |
Label | |||
Data Representation | MVS_32 | ||
Encoding | open_ed-1146 United Kingdom (OpenEdition) |
|
I am running the code on SAS Studio. How do i encode this dataset in readable format. Any help is appreciated
Firstly, check your sas session 's encoding by :
%put &=sysencoding. ;
Is it "open_ed-1146"?
If not add encoding= option to specify right encoding, and also check option recfm= and termstr=
infile "PZLN.VMO00.POL1501" dsd encoding='utf8' recfm=s370 termstr=nl;
Since you appear to be viewing the SAS dataset from your local SAS session via a remote LIBNAME so what is the encoding on both your remote and local SAS sessions? Run this in both and post the results:
proc options option = encoding;
run;
Also try downloading the dataset to your local SAS session using PROC DOWLOAD to see if that works OK.
Try viewing downloaded data and is it now readable?
rsubmit &MF.;
proc download data = test2x;
run;
endrsubmit;
Try asking SAS to transcode the data before trying to view it.
You might try adding the INENCODING option to the LIBNAME statement.
You might also check what types of bytes the text file actual has. If the values are ASCII codes and not EBCDIC you might need to use the $ASCII informat instead of the $ informat in the INPUT statement. You could try asking SAS to dump a few lines to the log.
data _null_;
infile "PZLN.VMO00.POL1501" obs=5;
input;
list;
run;
PS Your INFILE statement and INPUT statements are at conflict with each other. You don't need to specify DSD if you plan to read the data using FORMATTED mode INPUT statement. And if the file is delimited then do not use formatted style in the INPUT statement, that will read through the delimiters, instead read the values in LIST mode.
Calling all data scientists and open-source enthusiasts! Want to solve real problems that impact your company or the world? Register to hack by August 31st!
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.
Ready to level-up your skills? Choose your own adventure.