Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: summing up digits and comparing to a check digit


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: summing up digits and comparing to a check digit
Date   Wed, 15 Mar 2006 15:43:11 -0000

It's on SSC, as indicated. But I suspect Michael 
Blasnik has solved your problem directly. 

Nick 
[email protected] 

Lia Orfei
 
> wow the very author - thanks - if only I could find the program!
 
Nick Cox 
 
> >-pnrcheck- from SSC covers the Swedish case. 
> >
> >In this case, look _inside_ the program 
> >for some ideas. String functions are not 
> >the only way. -mod()- is also useful. 
> >
> >The authors of -pnrcheck- are two Italians
> >and a Welshman, just who you would expect
> >to be working on Swedish identifiers. 

Lia Orfei

> >>I have a variable that contains 7-digit numbers; the first 
> >>digit is the 
> >>remainder of the sum of the last six digits divided by 10 
> >>(check digit)
> >>
> >>example: 1030332 => 0+3+0+3+3+2=11/10=1+1 => check digit=1
> >>              12050457 => 0+5+0+4+5+7=21/10=2+1 => check digit=1
> >>and so on.
> >>
> >>Now I want to assess whther the check digit is correct for 
> each entry.
> >>
> >>How do I calculate the partial sum of the contents of this variable?
> >>
> >>Extra challenge: some of the numbers sum up to 10, 20 etc so 
> >>the check 
> >>digit is actually 0 and it does not appear in the data for 
> >>some reason 
> >>(example 50456 is correct becasue 5+0+4+5+6=20 so the 
> remainder is 0).
> >>
> >>Any ideas?? I was thinking about using the string functions.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index