Hi ! According to the documentation send by Jaap Karman, SAS(R) 9.4 Language Reference: Concepts, Fourth Edition, we can read that: When Variable Length Equals ... Largest Integer z/OS Largest Integer Windows/UNIX 2 256 not applicable 3 65,536 8,192 4 16,777,216 2,097,152 5 4,294,967,296 536,870,912 6 1,099,511,627,776 137,438,953,472 7 281,474,946,710,656 35,184,372,088,832 8 (default) 72,057,594,037,927,936 9,007,199,254,740,992 When viewing this table, consider the following points: The minimum length for a SAS variable on Windows and UNIX operating systems is 3 bytes, and the maximum length is 8 bytes But we know that the lenght of a numeric variable affects only the output of that variable. So to extract the first digits using substr() function, you have to put the beginning position to 1 and the end position (count from the first digit to the last one to conder where the first digit represent 3 or 4 according to the numeric to treat) Exemples: data want; a = 123456789; phonenum = 3125551212 ; b=substr(a,1,7); /* to get 7, the first digit begin at 4*/ c=substr(a,1,11); mim=substr(phonenum,1,12); /*to get 12, the first digit begin at 3 */ run; proc print data=want; run;
... View more