Hi I am trying to sum a column in a table, how ever although the column contains numbers they have been saved as text. I know in SQL you can use the following code but I am struggling to use this code in SAS
select SUM(cast(AAAAAAAAAA as float))/1000000 from ##Temp1
Your help in this matter is much appreciated
What does your data look like?
Sounds like you need to convert the character values to numeric first and then calculate the sum from there, eg with PROC MEANS.
The data looks like this, quite a few decimal places
7333.83706005760236
-241.48477505034183
-3721.90979470953705
282.78293262436968
8401.59702862381179
319.66827473169031
9488.22997865952625
276.11825793635553
8379.37965250339576
1001.47034302957246
Thanks for your help, worked just as you described
With that many decimals you may run into numeric precision issues.
DO you have any other suggestions? I don't mind it rounding the decimals up to about 6-7 places
@zdassu wrote:
DO you have any other suggestions? I don't mind it rounding the decimals up to about 6-7 places
I brought up the issue in case you considered all of those digits as significant. Your calculations involving such numbers could be off in the last one or two decimals (or more if enough calculations are done). You just need to know your data and treat as appropriate for your purpose.
I obviously don't have your data but if there are digits that are not actually significant that you carry through calculations then your result may imply precision that does not exist which has a chance of creating final statistics that are/are not significant based on using those values in a regression or similar procedure.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: