I'm processing a table with DI Studio (4.901)
I have a column that is numeric (best6.) input.. I need to convert the column to character (char40).. (simple enough)
BUT, if the numeric value of the input column is less than/equal to 99.... I need to add a zero to the leading side of the value in it's character result. I have to use this result character column to join with another table.. so a value of 99 needs to be '099'
I tried to use a case statement such as :
case
when <= 99
then cat('0', numeric_column)
else numeric_column
end
when I try to validate the code I get this error:
71 proc sql;
72 validate
73 select case
74 when <= 99
__
22
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.
75 then cat (0, channel_code)
76 else channel_code
77 end from work.etls_EFITable;
I think I'm just overlooking something simple in my logic..
Regards.
You want to use the Z format
something like
charvar=put(numvar,z3.);
You want to use the Z format
something like
charvar=put(numvar,z3.);
wow.. that was incredibly quick and painless.
that tried and worked excellent. I'm looking up that Z format to learn more about it.
Thanks for the help!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.