*(Q) I have a variable containing integers of 3 or more digits. * I need to extract the first digit if the integer has 3 digits and the * first 2 digits otherwise. *(A) posted to SPSSX-L list by Raynald Levesque on 2003/11/20. DATA LIST LIST /asoc. BEGIN DATA 813 1314 99999 888888 7777777 45321547 9999999999 END DATA. VARIABLE WIDTH asoc(10). DO IF asoc<10000. - COMPUTE asoc2=TRUNC(asoc/100). ELSE. - COMPUTE #digits=TRUNC(LG10(asoc)). - COMPUTE asoc2=TRUNC(asoc/(10**(#digits-1))). END IF. EXECUTE.