Ok, I've googled this and searched the sas website and i'm just not finding the answer to this most simple of questions:
I need to return the first digit of a numeric variable into a new variable. Can someone please give me the data step i need or the command in proc sql?
Hey KSharp,
Is there a way to use this to create a numeric variable instead of a character one? or do i just need to convert it back to a numeric after i'm done?
> Hey KSharp,
> Is there a way to use this to create a numeric
> variable instead of a character one? or do i just
> need to convert it back to a numeric after i'm done?
>
> Thanks,
> cr
Not the best programming practice but if you leave off the length declaration the target variable will default to numeric and you'll get a numeric result and warnings in the log about conversion from string to numeric.
This is a format problem. What you want is the first significant digit of the number.
Check David Chapman's NESUG or SUGI paper on user define formats and proc report. He shows how to create a format to show the first two significant digits. Just modify that to show the first significant digit.