Are there any tools to test if a sas program conforms to "good programming practice" (defined by Phuse), or other autochecks that may be relevant?
Statisticians in the pharma industry have a traditional (arduous) approach to quality control. I wouldnt want to disrupt that. But can we learn something from the data scientists? Auto checks are inherent in their work flow, they even have a term for it - “Linting” means running a basic quality tool against your code. The tool will check your code syntax...
Github has checks built in (as a pre-commit) and there are add ons you can purchase: https://github.com/marketplace/codefactor . But if i search lexjansen's site and other sources I don't see relevant tools being developed by statistical programmers. Maybe I'm not looking in the right places?
I would therefore like to develop such a tool but it's unlikely I could do it on my own. Is there any interest from others in the SAS community to develop something along these lines, as an open source project?
to give a very basic example, according to gpp this should not appear in your code:
data a; set a;
it seems it should be easy to detect if this exists within a program, and many other deviations from gpp too.
(Let me know if my Q is better placed on a different board)
cheers
Hi @pmbrown ,
We (4GL Apps) completely agree - you shouldn't be pushing SAS code to GIT without basic lint checks (and testing)!
Which is why we built an MIT open source linter for SAS: https://github.com/sasjs/lint
As you point out, a linter is a fantastic tool to run as part of a git pre-commit hook, or during a CI/CID pipeline.
You can find it bundled already in the following SASjs tools:
Being MIT licensed, you can fork and include it within any tool you wish, no restrictions whatsoever.
We're looking for partners and sponsors and contributors to improve the tool. Just contact me here (PM) or on the website: https://sasapps.io/contact
The full list of rules can be found in this JSON file: https://github.com/sasjs/lint#linting
And a video here: https://communities.sas.com/t5/SAS-Hacker-s-Hub/Hacker-tip-5-Linting-SAS-Code/td-p/801098
Anyone is free to contribute rules - we wrote a contributors guide here: https://github.com/sasjs/lint/blob/main/CONTRIBUTING.md
By the way - you can also fix a lot of issues (such as your example of avoiding basic REPLACEing of datasets) by simply running SAS in strict mode - see this macro (which runs at the start of ALL the apps my team produce): https://core.sasjs.io/mp__init_8sas.html
Hi @pmbrown ,
We (4GL Apps) completely agree - you shouldn't be pushing SAS code to GIT without basic lint checks (and testing)!
Which is why we built an MIT open source linter for SAS: https://github.com/sasjs/lint
As you point out, a linter is a fantastic tool to run as part of a git pre-commit hook, or during a CI/CID pipeline.
You can find it bundled already in the following SASjs tools:
Being MIT licensed, you can fork and include it within any tool you wish, no restrictions whatsoever.
We're looking for partners and sponsors and contributors to improve the tool. Just contact me here (PM) or on the website: https://sasapps.io/contact
The full list of rules can be found in this JSON file: https://github.com/sasjs/lint#linting
And a video here: https://communities.sas.com/t5/SAS-Hacker-s-Hub/Hacker-tip-5-Linting-SAS-Code/td-p/801098
Anyone is free to contribute rules - we wrote a contributors guide here: https://github.com/sasjs/lint/blob/main/CONTRIBUTING.md
By the way - you can also fix a lot of issues (such as your example of avoiding basic REPLACEing of datasets) by simply running SAS in strict mode - see this macro (which runs at the start of ALL the apps my team produce): https://core.sasjs.io/mp__init_8sas.html
fantastic! thanks for all the info, i look forward to checking it out. We will incorporate what we can into our workflow .. maybe i can give an update when we have done that. cheers
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.