When writing “PROC SQL” statements in SAS, you have the choice to put your commas at the beginning (leading) or at the end (trailing) of your lines when selecting multiple columns.
Here’s an example of trailing commas:
1 2 3 4 5 6 PROC SQL; SELECT column1, column2, column3 FROM dataset; QUIT;
And here’s an example of leading commas:
1 2 3 4 5 6 PROC SQL; SELECT column1 ,column2 ,column3 FROM dataset; QUIT;
Trailing Comma strengths: Readability: Trailing commas are more in line with English punctuation norms and can be more intuitive to read.
Universality: The use of trailing commas is more common across different programming languages, making it easier for multi-language coders to adapt.
Leading Comma advantages: Error Prevention: Leading commas can help prevent errors. When adding a new line, you’re forced to put the comma before writing anything else. This can minimize the chance of forgetting a comma.
Code Cleanliness: If you want to comment out or remove a line of code, you don’t need to worry about the comma on the previous line. Each line is independent of others.
Ultimately, the choice between leading and trailing commas ultimately comes down to your personal preferences or department practices.
Personally, I have adopted leading commas for the reasons mentioned above.