Hi All,
I facing some issue with the sas jcl coding
i used to print my ls_addres_id in PIB format (in the input for reading purpose )
and i want to the output in $char12 format (for writing purpose )
i tried to convert the pib to char by using INPUT function but unble get the exact results
i'm getting ls_address_id already difined has numeric , plz find below the code
DATA RAM_;
INFILE karli2a DSD;
INPUT @1 TEXT $CHAR60.
@61 LS_ADDRESS_ID PIB4.;
LS_ADDRESS_ID = INPUT(ADDRESS_ID,12.);
RUN;
DATA VIG_;
SET RAM_;
FILE SYSOUT;
PUT @1 TEXT $CHAR60.
@61 LS_ADDRESS_ID 12.;
RUN;
PROC PRINT DATA = VIG_; RUN;
WARNING: Variable LS_ADDRESS_ID has already been defined as numeric.
14 RUN;
plz give sum suggestions to find out the results
Thanks & regards
N muralikrishna
The message is clear:
ADDRESS_ID is a numeric.
The input function expects a string. Hence the message.
> i tried to convert the pib to char by using INPUT function
The put function does that.
Also, try to type complete words please (not plz).
Or, to left-align:
ADDRESS_ID_CHAR = put( LS_ADDRESS_ID, 12. -L );
Take care of which type your variables and values are:
DATA RAM_;
INFILE karli2a DSD;
INPUT
@1 TEXT $CHAR60.
@61 ADDRESS_ID PIB4.
;
/* you now have a numeric variable, the values of which were read with a binary format */
LS_ADDRESS_ID = PUT(ADDRESS_ID,12.);
/* the new variable is of type character with a length of 12, and contains a human-readable number */
RUN;
DATA VIG_;
SET RAM_;
FILE SYSOUT;
PUT
@1 TEXT $CHAR60.
@61 LS_ADDRESS_ID $char12.
;
/* since LS_ADDRESS_ID is character, use a character format */
RUN;
Please post the log of BOTH steps. Use the {i} button for posting logs, and the "little running man" for code. Both buttons appear when posting in Rich Text.
I am asking because my code (first data step) would define LS_ADDRESS_ID as character, while your ERROR implies that it is numeric.
You must be more careful in copying code from here to your environment.
This is the code I gave you:
DATA RAM_;
INFILE karli2a DSD;
INPUT
@1 TEXT $CHAR60.
@61 ADDRESS_ID PIB4.
;
/* you now have a numeric variable, the values of which were read with a binary format */
LS_ADDRESS_ID = PUT(ADDRESS_ID,12.);
/* the new variable is of type character with a length of 12, and contains a human-readable number */
RUN;
and this is the corresponding part in your log:
2 INFILE kirlaA DSD; 3 INPUT 4 V1 TEXT $CHAR60. 5 @61 LS_ADDRESS_ID PIB4.; 6 LS_ADDRESS_ID = PUT(ADDRESS_ID,12.); 7 RUN;
Note which variable is read with the pib4. informat.
You really MUST now start to follow our advice. PLEASE (and I mean that!!!!) USE THE {i} BUTTON FOR POSTING LOGS!
And post the WHOLE(!) log from these steps. The snippets you supply are useless for diagnosing what's wrong. Especially since you seem to be typing them off a screen. SAS will never issue a
waARnING:
it's always a
WARNING
!
Just copy/paste the log text. We need to see the truth, the whole truth, and nothing but the truth.
Take your time copying code; if possible at all, do a copy/paste from here to your code editor to prevent typos.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.