Prev: perl REGEX -- What does it mean that regexes are greedy? How can I get around it?
Next: Finding Predcied values with confidence level based on the regression model
From: Henry on 8 Mar 2010 21:57 Dear all, I have a very simple question. I tried to add the leading zeros before the values like: 111 112 113 I will like to have the following: 0111 0112 0113 I use the put function like data new; set old; newsic= put(sic, z4.); run; But the log gives me this information: ERROR 48-59: The format $Z was not found or could not be loaded. I am not sure if there is any problem as it seems to be easy?? Any suggestions? Thank you so mcuh!
From: Tom Abernathy on 8 Mar 2010 22:58 Henry - The error message is saying that your old variable SIC was already a character variable and not a number. You can convert it to a number with the INPUT function. newsic = put( input(sic,4.), z4. ); You could also just prefix the zeros as characters. if length(sic) >= 4 then newsic=sic; else newsic=repeat('0',4-length(sic)-1)||sic; Note that the -1 is needed because the REPEAT function counts funny. - Tom On Mar 8, 9:57 pm, Henry <chchanghe...(a)gmail.com> wrote: > Dear all, > > I have a very simple question. > > I tried to add the leading zeros before the values like: > 111 > 112 > 113 > > I will like to have the following: > 0111 > 0112 > 0113 > > I use the put function like > > data new; > set old; > newsic= put(sic, z4.); > run; > > But the log gives me this information: > ERROR 48-59: The format $Z was not found or could not be loaded. > > I am not sure if there is any problem as it seems to be easy?? > > Any suggestions? Thank you so mcuh!
From: Henry on 9 Mar 2010 00:02
Hi Tom, I found the problem after posting it. I actually followed the second way as you suggested. Thank you so much for your prompt reply!!! On Mar 8, 8:58 pm, Tom Abernathy <tom.aberna...(a)gmail.com> wrote: > Henry - > The error message is saying that your old variable SIC was already a > character variable and not a number. > You can convert it to a number with the INPUT function. > > newsic = put( input(sic,4.), z4. ); > > You could also just prefix the zeros as characters. > if length(sic) >= 4 then newsic=sic; > else newsic=repeat('0',4-length(sic)-1)||sic; > > Note that the -1 is needed because the REPEAT function counts funny. > > - Tom > > On Mar 8, 9:57 pm, Henry <chchanghe...(a)gmail.com> wrote: > > > Dear all, > > > I have a very simple question. > > > I tried to add the leading zeros before the values like: > > 111 > > 112 > > 113 > > > I will like to have the following: > > 0111 > > 0112 > > 0113 > > > I use the put function like > > > data new; > > set old; > > newsic= put(sic, z4.); > > run; > > > But the log gives me this information: > > ERROR 48-59: The format $Z was not found or could not be loaded. > > > I am not sure if there is any problem as it seems to be easy?? > > > Any suggestions? Thank you so mcuh! |