SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Re: Question to convert the field type in Data Management Studio 2.4

Reply
Contributor
Posts: 21

Re: Question to convert the field type in Data Management Studio 2.4

I have tried the above tostring function and it is working fine. Thank you so much for the above solution and also regret for the late reply.

I have one more question to ask, I have the field COCD with the len 1, 2, 3, and 4 digits. The COCD column must consist of 4 len number as per our requirement so i have to prefix each company code with '0' to make it 4 digit. Is there any solution or functionality i can use to change the len to 4 digits?

I have used below the expression but not yielding result:

if len(COCD) == 1 then cocd_text = left(000,COCD)

COCDRequired Output
10001
20002
110011
220022
3330333
44444444


Regards,
Shaheen

SAS Employee
Posts: 85

Re: Question to convert the field type in Data Management Studio 2.4

This was answered here:

but to save you a click here is the solution:

/* Pre-processing Expression*/

string desired_output

hidden integer i

desired_output = ''

i = 0

/*Expression*/

if len(`COCD`) < 4

  begin

  desired_output = `COCD`

  while i <  (4 - len(`COCD`))

  begin

  desired_output = '0' & desired_output

  i = i + 1

  end

  end

else

  desired_output = `COCD`

  i = 0

dm_expression.png

Ask a Question
Discussion stats
  • 1 reply
  • 211 views
  • 0 likes
  • 2 in conversation