[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Formatting fields
I have two files one file has ID in the form str10 the other in the form 12.0g.
I want to merge the data by the ID
When I perform a command to change the str var to numeric, the new numeric
field comes in as a float %9.0g
When I reformat that field to 12.0g, the field values change completely.
For long IDs string variables are recommended. In numeric variables the
standard float type has a precision of 7 digits, so it must be declared
double. Take a look with -describe- if your numeric ID is -double- (this
has nothing to do with the format). If it is -float- you have a serious
If the numeric ID is double, OK. If the name of the numeric ID is -idn-,
create the corresponding string (ids) by:
. generate ids = string(idn, "%010.0f")
%010.0f creates a fixed format. The leading 0 means that strings shorter
than 10 characters will have leading 0s rather than blanks.
This works with version 8 and 9. I am not sure about version 6.
Hope this helps
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000 Aarhus C, Denmark
Phone, work: +45 8942 6090
Phone, home: +45 8693 7796
Fax: +45 8613 1580
* For searches and help try: