Hi there,
I need to read a SAS file, which saved on Mainframe. The file has a numeric variable with length of 2. How can I load this file into my Windows SAS? I have try to use the length statement, but it always give me this error: "One or more numeric variables could not be converted to the target representation
because they are shorter than the target representation allows."
Really appreciate your help.
So you are connecting to a SAS/Share server on the mainframe.
This old 9.1 documentation indicates you cannot transfer the 2 byte numeric variables that way. https://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_91/share_ug_7261.pdf
Have someone with direct access to the mainframe convert the file. They could create a new dataset using LENGTH=3 for those variable(s). Perhaps even just create view for you to access.
If you have access to use SAS/Connect instead of SAS/Share then try using PROC DOWNLOAD to copy the data.
rsubmit;
libname CBIT "mainframe_file_name" access=readonly ;
proc download inlib=CBIT outlib=work;
run;
endrsubmit;
If that doesn't work then try making a work dataset on the remote that fixes the lengths and downloading that.
rsubmit;
libname CBIT "mainframe_file_name" access=readonly ;
data work.copy;
set CBIT.MYTABLE;
length _numeric_ 8;
run;
proc download data=copy out=work.mytable;
run;
endrsubmit;
So you cannot use CEDA to read Mainframe files on Window, so HOW are you trying to read the dataset in Windows?
Show the code you ran that generated that message. Use the Insert Code button to get a pop-up window to paste/edit the lines from the SAS log that show the code and the errors.
LENGTH of a variable is how many bytes to store in the dataset. For numeric variables if you use a length less than 8 it just throws away the lower order bytes. In general you should always just use 8 bytes for numbers so the full 64 bit floating point number is saved.
Because the Mainframe uses a different floating point representation you can use a storage length of 2. But on Window/Unix that wouldn't leave any room for storing the actual number. So the minimum length you can use is 3.
Hi Tom,
I need to get the data source form Mainframe. I have assign a libname to the mainframe server. Then I run a simple data step to transfer the data into my local PC, then work on it. The variable "Status" has the length of 2 (numeric). There is the error msg:
data sample;
length status 8.;
SET CBIT.DATA ;
run;
ERROR: One or more numeric variables could not be converted to the target representation
because they are shorter than the target representation allows.
NOTE: The DATA step has been abnormally terminated.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SAMPLE may be incomplete. When this step was stopped there were 0
observations and 7 variables.
WARNING: Data set WORK.SAMPLE was not replaced because this step was stopped.
What is the CBIT libref pointing at? Are you using SAS/Connect? SAS/Share?
So you are connecting to a SAS/Share server on the mainframe.
This old 9.1 documentation indicates you cannot transfer the 2 byte numeric variables that way. https://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_91/share_ug_7261.pdf
Have someone with direct access to the mainframe convert the file. They could create a new dataset using LENGTH=3 for those variable(s). Perhaps even just create view for you to access.
If you have access to use SAS/Connect instead of SAS/Share then try using PROC DOWNLOAD to copy the data.
rsubmit;
libname CBIT "mainframe_file_name" access=readonly ;
proc download inlib=CBIT outlib=work;
run;
endrsubmit;
If that doesn't work then try making a work dataset on the remote that fixes the lengths and downloading that.
rsubmit;
libname CBIT "mainframe_file_name" access=readonly ;
data work.copy;
set CBIT.MYTABLE;
length _numeric_ 8;
run;
proc download data=copy out=work.mytable;
run;
endrsubmit;
You need to know what members are stored in the library that is the physical file on the mainframe.
I just used MYTABLE as a place holder. Use the real member name.
The interface makes it hard to see the full thread when replying. Looking at your earlier posts you where using a member name of DATA before.
Read the notes in the log to see more about what is happening. Are you sure you remote submitted the code to the same server you where connected to with your REMOTE libref? The same file?
Try running proc contents on the mainframe side to see how many observations. Perhaps there were always zero obs, but SAS was still throwing the error because of the length of 2 even though it wouldn't matter if there wasn't any values to convert.
The second code works ^O^. Thanks so much.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.