From: Raj on 6 Jan 2010 14:38 Hi, I have to read a CSV file. In one column i have values of differrent length but the column length is 5 now i want to keep leading zeros if the length of the value is not 5. for example: A 1 23 55555 Ouput should be: A 00001 00023 55555 Could please help me with some suggestions. Thanks! Raj
From: Nathaniel Wooding on 6 Jan 2010 14:48 Assuming that the column is numeric and a character variable would work, try Data start; input id; cards; 1 23 55555 run; Data wanted; set start; CharID = Put( id , z5.); run; Nat Wooding -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Raj Sent: Wednesday, January 06, 2010 2:39 PM To: SAS-L(a)LISTSERV.UGA.EDU Subject: Leading Zeros Hi, I have to read a CSV file. In one column i have values of differrent length but the column length is 5 now i want to keep leading zeros if the length of the value is not 5. for example: A 1 23 55555 Ouput should be: A 00001 00023 55555 Could please help me with some suggestions. Thanks! Raj CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
From: NordlDJ on 6 Jan 2010 14:48 > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Raj > Sent: Wednesday, January 06, 2010 11:39 AM > To: SAS-L(a)LISTSERV.UGA.EDU > Subject: Leading Zeros > > Hi, > > I have to read a CSV file. > In one column i have values of differrent length but the column length > is 5 now i want to keep leading zeros if the length of the value is > not 5. > > for example: > > A > > 1 > > 23 > > 55555 > > Ouput should be: > > A > > 00001 > > 00023 > > 55555 > > Could please help me with some suggestions. > > Thanks! > > Raj Raj, Output your data with a z5. Format. Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204
From: "Schwarz, Barry A" on 6 Jan 2010 15:19 Read the value using a character informat. Determine if the value is numeric (the trim and notdigit functions may be useful here. If not numeric, leave unchanged. If numeric, use the put function and z5. format to insert zeros. -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Raj Sent: Wednesday, January 06, 2010 11:39 AM To: SAS-L(a)LISTSERV.UGA.EDU Subject: Leading Zeros Hi, I have to read a CSV file. In one column i have values of differrent length but the column length is 5 now i want to keep leading zeros if the length of the value is not 5. for example: A 1 23 55555 Ouput should be: A 00001 00023 55555 Could please help me with some suggestions.
|
Pages: 1 Prev: princomp question - 95% CI for loadings Next: Fwd: Issue with %let |