BookmarkSubscribeRSS Feed
rohitkrishna
Calcite | Level 5

Hi All,

I have query on sas mainframe, i want to convert numeric value to character value  so kindly help out for the solution

so please find below  the sas code and give sum suggestions { and basically my requirement are, ls_address_id variable have binary values like  "õUA000000001250545 "    , and while reading the input i want it to be in readable format so i gave pib4 . format for that and i got the exact results and it's readable"4042322160" , now "i want to print the results in output file in a non readable format like in input " "õUA000000001250545 "  (like that) but while trying to assign $char12.  i'm getting error { ls_address_id has already defined has numeric }

so kindly give the solution for that

{

{1 DATA RAM_;
WARNING: The Base Product product with which DATASTEP is associated will expire
installation representative to have it renewed.
2 INFILE karli2a DSD;
3 INPUT
4 @1 TEXT $CHAR60.
5 @61 LS_ADDRESS_ID PIB4.
6 ;
7 LS_ADDRESS_ID = PUT(ADDRESS_ID,12.);
8 RUN;
Character values have been converted to numeric values at the places give
7:18
9 DATA VIG_;
10 SET RAM_;
11 FILE SYSOUT;
12 PUT
13 @1 TEXT $CHAR60.
14 @61 LS_ADDRESS_ID $CHAR12.
+ ________
+ ________
+ ________
48
+ 48
+ 48
ERROR 48-59: The format CHAR was not found or could not be loaded.
+ERROR 48-59: The format CHAR was not found or could not be loaded.
+ERROR 48-59: The format CHAR was not found or could not be loaded.

15 ;
WARNING: Variable LS_ADDRESS_ID has already been defined as numeric. }
thanks & regards
N muralikrishna

 

6 REPLIES 6
rohitkrishna
Calcite | Level 5
Hi, Kurtbremser,
Thanks for the replay
last day i tried your code & it's working
but my requirment was not to be read only i want to print the data in non readable format so above the code i mention inplace of put i mention input function i got the above error { I UNDERSTOOD WHAT YOU CODE I FLOWED AND IT'S WORKED BUT MY REQUIREMENT IS DIFFERENT }
{ DATA RAM_;
INFILE CLSTA2A DSD;
INPUT
@1 TEXT $CHAR60.
@61 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.
;
}
Thanks & Regards
N muralikrishna
Kurt_Bremser
Super User

Your input statement creates a numeric variable. To convert that to character, use the put() function:

LS_ADDRESS_ID = PUT(ADDRESS_ID,12.);

with a numeric output format.

Next, use a character format for printing that:

PUT
  @1 TEXT $CHAR60.
  @61 LS_ADDRESS_ID $char12.
;
rohitkrishna
Calcite | Level 5
and the above infile name is exact file name
and below the log please find the log and i'm not getting any error but i'm not able to get exact results
{
2 INFILE CLSTA2A DSD;
3 INPUT
4 @1 TEXT $CHAR60.
5 @61 ADDRESS_ID PIB4.
6 ;
7 LS_ADDRESS_ID = INPUT(ADDRESS_ID,$12.);
8 RUN;

NOTE: Numeric values have been converted to character values at the places given
7:23

!
DATA VIG_;
NG: The Base Product product with which DAT
installation representative to have it
SET RAM_;
FILE SYSOUT;
PUT
@1 TEXT $CHAR60.
@61 LS_ADDRESS_ID 12.
;
}
The below the results i got

LS_ADDRESS_
ID

4042322160
4042322160
4042322160
but i don't want to print the readable format i want to be print it in non readable format like below
õUA000000001250545 |
UA000000002009688 | > those are the input Ls_address_id (values) non readble format
þUA000000002009855

Thanks & regards
N muralikrishna
Astounding
PROC Star
I participated in that previous discussion. Based on that, here is a small change to make, with no further explanation.

Make one change and one change only. Any additional changes will cause an error. In the last line of the top INPUT statement, remove "LS_" :

@61 ADDRESS_ID PIB4.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1329 views
  • 0 likes
  • 3 in conversation