Hi,
Quick question on count and format
select xx_yy,
count(1) format = comma12. as aci_knt
From wkly_wxxx_fnl
what does the count and format do in this code. please help me
@soujik wrote:
what does the comma12.
is it put comma after 12 digits?
As I said, it adds commas properly to your number. I have never seen a number with a comma after 12 digits. Since two people have given you a link to the documentation for the COMMA format, you can also look at the examples there.
Count(1) counts the number of records in column 1 (which is the variable named xx_yy), which is also the same as the number of records in the data set; and format displays the result using the COMMA. format (in other words, with appropriate commas).
what does the comma12.
is it put comma after 12 digits?
You can follow Maxim 4 and simply try it.
Or you follow Maxim 1 and Read the Documentation: COMMAw. Format
@soujik wrote:
what does the comma12.
is it put comma after 12 digits?
As I said, it adds commas properly to your number. I have never seen a number with a comma after 12 digits. Since two people have given you a link to the documentation for the COMMA format, you can also look at the examples there.
COUNT() counts the number of times is argument is not missing. So COUNT(1) is the same thing as COUNT(*), it just counts the number of observations.
FORMAT= is used to attach a format to the variable. The COMMA format is used to display number with a comma as the thousands separator. 12 is the width of the format, how many bytes it prints. So COMMA12 will show numbers in the style of ,234,678,012 . So use 12 is a little silly for positive numbers. Either use COMMA11. if you expect numbers smaller than 1 billion or use something wider than 12 if you expect counts over 1 billion.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.