mirror of
https://github.com/sasjs/core.git
synced 2026-01-06 00:50:05 +00:00
Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9185a2bf2 | ||
|
|
f0b77dfc6a | ||
|
|
91c4b87496 | ||
|
|
111d0dffc3 | ||
|
|
4f481ec8b4 | ||
|
|
b8cec22a88 | ||
|
|
6b1accdd6b | ||
|
|
949b406c23 | ||
|
|
fc90a7f928 | ||
|
|
d0bd88907f | ||
| 4e21772207 | |||
|
|
39f700bed2 | ||
|
|
dcb7958950 | ||
|
|
146610b5a7 | ||
|
|
9887efcf60 | ||
|
|
a2c7bdafb4 | ||
|
|
c58b5c7a52 | ||
|
|
22c7e5b4dd | ||
|
|
244171f8c4 | ||
|
|
fd765e2d68 | ||
| 840cb5ef44 | |||
| 918ce96fce | |||
| f1712c34e8 | |||
| 11ec20b472 | |||
| f42f111462 | |||
| 907725c5ba | |||
| 95b78b91e1 | |||
| e4771b9c14 | |||
| ba8190883e | |||
|
|
32dd057e83 | ||
|
|
7471bd42a4 | ||
|
|
702a4ecd3a | ||
|
|
5da97295ff | ||
|
|
dc556bdef0 | ||
|
|
111731bf35 | ||
|
|
2c526cf9dd | ||
|
|
660e02193f | ||
|
|
00b4dee86e | ||
|
|
3913825c22 | ||
|
|
0f143d603b | ||
|
|
f1d5fa2c0a | ||
|
|
a88689428f | ||
|
|
8843fa8bfc | ||
|
|
22d046cf5c | ||
|
|
29e3eb34aa | ||
|
|
1af52a6683 | ||
|
|
fc0c96dd94 | ||
|
|
b9c4882553 | ||
|
|
011b2b185c | ||
|
|
dbc23550ac | ||
|
|
8910840ccc | ||
|
|
4ef571032d | ||
|
|
e01cd8cd16 | ||
|
|
00628ec78a | ||
|
|
f4e6a487f3 | ||
|
|
b7afecdf81 | ||
|
|
19eb348f0e | ||
|
|
f420ac2abf | ||
|
|
7edec1ad8a | ||
|
|
62d7bce249 | ||
|
|
fe6c9a793b | ||
|
|
8e13943356 | ||
|
|
04df9600e0 | ||
|
|
e2b0aabfa4 | ||
|
|
c52a623630 | ||
|
|
cf348e8016 | ||
|
|
6502fc4982 | ||
|
|
ef574f6319 | ||
|
|
5b251006cd | ||
|
|
b353acec47 | ||
|
|
8b148c3916 | ||
|
|
2efdcec54c | ||
|
|
f832e93f4b | ||
|
|
f37c2e5867 | ||
|
|
6f8ec5d5a8 | ||
|
|
6521ade608 | ||
|
|
2666bbc85e | ||
|
|
ee35f47f4f |
@@ -135,6 +135,15 @@
|
|||||||
"contributions": [
|
"contributions": [
|
||||||
"code"
|
"code"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "henrik-forsell",
|
||||||
|
"name": "Henrik Forsell",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/109935936?v=4",
|
||||||
|
"profile": "https://github.com/henrik-forsell",
|
||||||
|
"contributions": [
|
||||||
|
"doc"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
|
|||||||
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1,3 +1,3 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
github: [sasjs]
|
custom: https://getalby.com/p/sasjs
|
||||||
|
|||||||
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -15,3 +15,4 @@ What code changes have been made to achieve the intent.
|
|||||||
- [ ] Code is formatted correctly (`sasjs lint`).
|
- [ ] Code is formatted correctly (`sasjs lint`).
|
||||||
- [ ] Any new functionality has been unit tested.
|
- [ ] Any new functionality has been unit tested.
|
||||||
- [ ] All unit tests are passing (`sasjs test`).
|
- [ ] All unit tests are passing (`sasjs test`).
|
||||||
|
- [ ] `all.sas` has been regenerated (`python3 build.py`)
|
||||||
|
|||||||
25
.github/vpn/config.ovpn
vendored
Normal file
25
.github/vpn/config.ovpn
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Client
|
||||||
|
client
|
||||||
|
tls-client
|
||||||
|
dev tun
|
||||||
|
# this will connect with whatever proto DNS tells us (https://community.openvpn.net/openvpn/ticket/934)
|
||||||
|
proto tcp
|
||||||
|
remote vpn.4gl.io 7494
|
||||||
|
resolv-retry infinite
|
||||||
|
cipher AES-256-CBC
|
||||||
|
auth SHA256
|
||||||
|
script-security 2
|
||||||
|
keepalive 10 120
|
||||||
|
remote-cert-tls server
|
||||||
|
|
||||||
|
# Keys
|
||||||
|
ca ca.crt
|
||||||
|
cert user.crt
|
||||||
|
key user.key
|
||||||
|
tls-auth tls.key 1
|
||||||
|
|
||||||
|
# Security
|
||||||
|
nobind
|
||||||
|
persist-key
|
||||||
|
persist-tun
|
||||||
|
verb 3
|
||||||
9
.github/workflows/main.yml
vendored
9
.github/workflows/main.yml
vendored
@@ -15,7 +15,14 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Semantic Release
|
- name: Semantic Release
|
||||||
uses: cycjimmy/semantic-release-action@v2
|
uses: cycjimmy/semantic-release-action@v3
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
- name: SAS Packages Release
|
||||||
|
run: |
|
||||||
|
npx @sasjs/cli compile job -s sasjs/utils/create_sas_package.sas -o sasjsbuild
|
||||||
|
# this part depends on https://github.com/sasjs/server/issues/307
|
||||||
|
# sasjs run sasjsbuild/jobs/utils/create_sas_package.sas -t sas9
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
45
.github/workflows/run-tests.yml
vendored
45
.github/workflows/run-tests.yml
vendored
@@ -21,32 +21,49 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
- name: Write VPN Files
|
||||||
|
run: |
|
||||||
|
echo "$CA_CRT" > .github/vpn/ca.crt
|
||||||
|
echo "$USER_CRT" > .github/vpn/user.crt
|
||||||
|
echo "$USER_KEY" > .github/vpn/user.key
|
||||||
|
echo "$TLS_KEY" > .github/vpn/tls.key
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CA_CRT: ${{ secrets.CA_CRT}}
|
||||||
|
USER_CRT: ${{ secrets.USER_CRT }}
|
||||||
|
USER_KEY: ${{ secrets.USER_KEY }}
|
||||||
|
TLS_KEY: ${{ secrets.TLS_KEY }}
|
||||||
|
|
||||||
|
- name: Install Open VPN
|
||||||
|
run: |
|
||||||
|
sudo apt install apt-transport-https
|
||||||
|
sudo wget https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub
|
||||||
|
sudo apt-key add openvpn-repo-pkg-key.pub
|
||||||
|
sudo wget -O /etc/apt/sources.list.d/openvpn3.list https://swupdate.openvpn.net/community/openvpn3/repos/openvpn3-jammy.list
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install openvpn3=17~betaUb22042+jammy
|
||||||
|
- name: Start Open VPN 3
|
||||||
|
run: openvpn3 session-start --config .github/vpn/config.ovpn
|
||||||
- name: Install Doxygen
|
- name: Install Doxygen
|
||||||
run: sudo apt-get install doxygen
|
run: sudo apt-get install doxygen
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Check code style
|
- name: Check code style (aborts if errors found)
|
||||||
run: npm run lint
|
run: npx sasjs lint
|
||||||
|
|
||||||
- name: Add client
|
- name: Add client
|
||||||
run: echo "CLIENT=${{secrets.CLIENT}}"> .env.viya
|
run: echo "CLIENT=${{secrets.SAS9_4GL_IO_CLIENT}}"> .env.server
|
||||||
|
|
||||||
- name: Add secret
|
|
||||||
run: echo "SECRET=${{secrets.SECRET}}" >> .env.viya
|
|
||||||
|
|
||||||
- name: Add access token
|
- name: Add access token
|
||||||
run: echo "ACCESS_TOKEN=${{secrets.ACCESS_TOKEN}}" >> .env.viya
|
run: echo "ACCESS_TOKEN=${{secrets.SAS9_4GL_IO_ACCESS_TOKEN}}" >> .env.server
|
||||||
|
|
||||||
- name: Add refresh token
|
- name: Build & Deploy Project to SAS server
|
||||||
run: echo "REFRESH_TOKEN=${{secrets.REFRESH_TOKEN}}" >> .env.viya
|
run: npx sasjs cbd -t server
|
||||||
|
|
||||||
- name: Build Project
|
- name: Run all tests
|
||||||
run: npm run build
|
run: npx sasjs test -t server
|
||||||
|
|
||||||
- name: Run SASjs tests
|
|
||||||
run: npm run test
|
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
CLIENT: ${{secrets.CLIENT}}
|
CLIENT: ${{secrets.CLIENT}}
|
||||||
|
|||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -10,4 +10,6 @@ sasjsresults/
|
|||||||
mc_*
|
mc_*
|
||||||
|
|
||||||
# ignore .env files as they can contain sasjs access tokens
|
# ignore .env files as they can contain sasjs access tokens
|
||||||
*.env*
|
*.env*
|
||||||
|
|
||||||
|
~
|
||||||
|
|||||||
26
.sasjslint
26
.sasjslint
@@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
"noTrailingSpaces": true,
|
"noTrailingSpaces": true,
|
||||||
"noEncodedPasswords": true,
|
"noEncodedPasswords": true,
|
||||||
"hasDoxygenHeader": true,
|
"hasDoxygenHeader": true,
|
||||||
"hasMacroNameInMend": true,
|
"hasMacroNameInMend": true,
|
||||||
"hasMacroParentheses": true,
|
"hasMacroParentheses": true,
|
||||||
"noNestedMacros": false,
|
"lineEndings": "lf",
|
||||||
"noSpacesInFileNames": true,
|
"noGremlins": true,
|
||||||
"maxLineLength": 300,
|
"noNestedMacros": false,
|
||||||
"lowerCaseFileNames": true,
|
"noSpacesInFileNames": true,
|
||||||
"noTabIndentation": true,
|
"maxLineLength": 300,
|
||||||
"indentationMultiple": 2
|
"lowerCaseFileNames": true,
|
||||||
}
|
"noTabs": true,
|
||||||
|
"indentationMultiple": 2
|
||||||
|
}
|
||||||
|
|||||||
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -6,5 +6,7 @@
|
|||||||
"editor.rulers": [
|
"editor.rulers": [
|
||||||
80
|
80
|
||||||
],
|
],
|
||||||
"files.trimTrailingWhitespace": true
|
"files.trimTrailingWhitespace": true,
|
||||||
|
"sasjs-for-vscode.target": "docsonly",
|
||||||
|
"sasjs-for-vscode.isLocal": true
|
||||||
}
|
}
|
||||||
39
README.md
39
README.md
@@ -2,8 +2,6 @@
|
|||||||
[![npm package][npm-image]][npm-url]
|
[![npm package][npm-image]][npm-url]
|
||||||
[![Github Workflow][githubworkflow-image]][githubworkflow-url]
|
[![Github Workflow][githubworkflow-image]][githubworkflow-url]
|
||||||

|

|
||||||

|
|
||||||
[](/LICENSE)
|
|
||||||

|

|
||||||
[](https://github.com/sasjs/core/issues?q=is%3Aissue+is%3Aclosed)
|
[](https://github.com/sasjs/core/issues?q=is%3Aissue+is%3Aclosed)
|
||||||
[](https://github.com/sasjs/core/issues)
|
[](https://github.com/sasjs/core/issues)
|
||||||
@@ -248,7 +246,7 @@ The following repositories are also worth checking out:
|
|||||||
|
|
||||||
## Contributors ✨
|
## Contributors ✨
|
||||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||||
[](#contributors-)
|
[](#contributors-)
|
||||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||||
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
||||||
|
|
||||||
@@ -256,22 +254,25 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<!-- prettier-ignore-start -->
|
<!-- prettier-ignore-start -->
|
||||||
<!-- markdownlint-disable -->
|
<!-- markdownlint-disable -->
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tbody>
|
||||||
<td align="center"><a href="https://github.com/allanbowe"><img src="https://avatars.githubusercontent.com/u/4420615?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Allan Bowe</b></sub></a><br /><a href="#business-allanbowe" title="Business development">💼</a> <a href="https://github.com/sasjs/core/commits?author=allanbowe" title="Code">💻</a> <a href="#content-allanbowe" title="Content">🖋</a> <a href="https://github.com/sasjs/core/commits?author=allanbowe" title="Documentation">📖</a> <a href="#infra-allanbowe" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-allanbowe" title="Maintenance">🚧</a> <a href="#mentoring-allanbowe" title="Mentoring">🧑🏫</a> <a href="#question-allanbowe" title="Answering Questions">💬</a> <a href="https://github.com/sasjs/core/pulls?q=is%3Apr+reviewed-by%3Aallanbowe" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/sasjs/core/commits?author=allanbowe" title="Tests">⚠️</a></td>
|
<tr>
|
||||||
<td align="center"><a href="https://github.com/rafgag"><img src="https://avatars.githubusercontent.com/u/69139928?v=4?s=100" width="100px;" alt=""/><br /><sub><b>rafgag</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=rafgag" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/allanbowe"><img src="https://avatars.githubusercontent.com/u/4420615?v=4?s=100" width="100px;" alt="Allan Bowe"/><br /><sub><b>Allan Bowe</b></sub></a><br /><a href="#business-allanbowe" title="Business development">💼</a> <a href="https://github.com/sasjs/core/commits?author=allanbowe" title="Code">💻</a> <a href="#content-allanbowe" title="Content">🖋</a> <a href="https://github.com/sasjs/core/commits?author=allanbowe" title="Documentation">📖</a> <a href="#infra-allanbowe" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-allanbowe" title="Maintenance">🚧</a> <a href="#mentoring-allanbowe" title="Mentoring">🧑🏫</a> <a href="#question-allanbowe" title="Answering Questions">💬</a> <a href="https://github.com/sasjs/core/pulls?q=is%3Apr+reviewed-by%3Aallanbowe" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/sasjs/core/commits?author=allanbowe" title="Tests">⚠️</a></td>
|
||||||
<td align="center"><a href="https://github.com/tmoody"><img src="https://avatars.githubusercontent.com/u/79837106?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Trevor Moody</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=tmoody" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/rafgag"><img src="https://avatars.githubusercontent.com/u/69139928?v=4?s=100" width="100px;" alt="rafgag"/><br /><sub><b>rafgag</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=rafgag" title="Code">💻</a></td>
|
||||||
<td align="center"><a href="https://krishna-acondy.io/"><img src="https://avatars.githubusercontent.com/u/2980428?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Krishna Acondy</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=krishna-acondy" title="Code">💻</a> <a href="#infra-krishna-acondy" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#blog-krishna-acondy" title="Blogposts">📝</a> <a href="#content-krishna-acondy" title="Content">🖋</a> <a href="#ideas-krishna-acondy" title="Ideas, Planning, & Feedback">🤔</a> <a href="#video-krishna-acondy" title="Videos">📹</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tmoody"><img src="https://avatars.githubusercontent.com/u/79837106?v=4?s=100" width="100px;" alt="Trevor Moody"/><br /><sub><b>Trevor Moody</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=tmoody" title="Code">💻</a></td>
|
||||||
<td align="center"><a href="https://github.com/saadjutt01"><img src="https://avatars.githubusercontent.com/u/8914650?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Muhammad Saad </b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=saadjutt01" title="Code">💻</a> <a href="#ideas-saadjutt01" title="Ideas, Planning, & Feedback">🤔</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://krishna-acondy.io/"><img src="https://avatars.githubusercontent.com/u/2980428?v=4?s=100" width="100px;" alt="Krishna Acondy"/><br /><sub><b>Krishna Acondy</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=krishna-acondy" title="Code">💻</a> <a href="#infra-krishna-acondy" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#blog-krishna-acondy" title="Blogposts">📝</a> <a href="#content-krishna-acondy" title="Content">🖋</a> <a href="#ideas-krishna-acondy" title="Ideas, Planning, & Feedback">🤔</a> <a href="#video-krishna-acondy" title="Videos">📹</a></td>
|
||||||
<td align="center"><a href="https://www.erudicat.com/"><img src="https://avatars.githubusercontent.com/u/25773492?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yury Shkoda</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=YuryShkoda" title="Code">💻</a> <a href="#infra-YuryShkoda" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#video-YuryShkoda" title="Videos">📹</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/saadjutt01"><img src="https://avatars.githubusercontent.com/u/8914650?v=4?s=100" width="100px;" alt="Muhammad Saad "/><br /><sub><b>Muhammad Saad </b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=saadjutt01" title="Code">💻</a> <a href="#ideas-saadjutt01" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||||
<td align="center"><a href="https://github.com/medjedovicm"><img src="https://avatars.githubusercontent.com/u/18329105?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mihajlo Medjedovic</b></sub></a><br /><a href="#infra-medjedovicm" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://www.erudicat.com/"><img src="https://avatars.githubusercontent.com/u/25773492?v=4?s=100" width="100px;" alt="Yury Shkoda"/><br /><sub><b>Yury Shkoda</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=YuryShkoda" title="Code">💻</a> <a href="#infra-YuryShkoda" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#video-YuryShkoda" title="Videos">📹</a></td>
|
||||||
</tr>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/medjedovicm"><img src="https://avatars.githubusercontent.com/u/18329105?v=4?s=100" width="100px;" alt="Mihajlo Medjedovic"/><br /><sub><b>Mihajlo Medjedovic</b></sub></a><br /><a href="#infra-medjedovicm" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td align="center"><a href="https://github.com/kkchandok"><img src="https://avatars.githubusercontent.com/u/46090627?v=4?s=100" width="100px;" alt=""/><br /><sub><b>kkchandok</b></sub></a><br /><a href="#ideas-kkchandok" title="Ideas, Planning, & Feedback">🤔</a></td>
|
<tr>
|
||||||
<td align="center"><a href="https://github.com/VladislavParhomchik"><img src="https://avatars.githubusercontent.com/u/83717836?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vladislav Parhomchik</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=VladislavParhomchik" title="Tests">⚠️</a> <a href="https://github.com/sasjs/core/pulls?q=is%3Apr+reviewed-by%3AVladislavParhomchik" title="Reviewed Pull Requests">👀</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kkchandok"><img src="https://avatars.githubusercontent.com/u/46090627?v=4?s=100" width="100px;" alt="kkchandok"/><br /><sub><b>kkchandok</b></sub></a><br /><a href="#ideas-kkchandok" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||||
<td align="center"><a href="https://github.com/vznesh"><img src="https://avatars.githubusercontent.com/u/28916792?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vignesh T.</b></sub></a><br /><a href="https://github.com/sasjs/core/issues?q=author%3Avznesh" title="Bug reports">🐛</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/VladislavParhomchik"><img src="https://avatars.githubusercontent.com/u/83717836?v=4?s=100" width="100px;" alt="Vladislav Parhomchik"/><br /><sub><b>Vladislav Parhomchik</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=VladislavParhomchik" title="Tests">⚠️</a> <a href="https://github.com/sasjs/core/pulls?q=is%3Apr+reviewed-by%3AVladislavParhomchik" title="Reviewed Pull Requests">👀</a></td>
|
||||||
<td align="center"><a href="https://github.com/yabwon"><img src="https://avatars.githubusercontent.com/u/9314894?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bart Jablonski</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=yabwon" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/vznesh"><img src="https://avatars.githubusercontent.com/u/28916792?v=4?s=100" width="100px;" alt="Vignesh T."/><br /><sub><b>Vignesh T.</b></sub></a><br /><a href="https://github.com/sasjs/core/issues?q=author%3Avznesh" title="Bug reports">🐛</a></td>
|
||||||
<td align="center"><a href="https://bandism.net/"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ikko Ashimine</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=eltociear" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yabwon"><img src="https://avatars.githubusercontent.com/u/9314894?v=4?s=100" width="100px;" alt="Bart Jablonski"/><br /><sub><b>Bart Jablonski</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=yabwon" title="Code">💻</a></td>
|
||||||
</tr>
|
<td align="center" valign="top" width="14.28%"><a href="https://bandism.net/"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=100" width="100px;" alt="Ikko Ashimine"/><br /><sub><b>Ikko Ashimine</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=eltociear" title="Code">💻</a></td>
|
||||||
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/henrik-forsell"><img src="https://avatars.githubusercontent.com/u/109935936?v=4?s=100" width="100px;" alt="Henrik Forsell"/><br /><sub><b>Henrik Forsell</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=henrik-forsell" title="Documentation">📖</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- markdownlint-restore -->
|
<!-- markdownlint-restore -->
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mf_abort(mac=mf_abort.sas, msg=, iftrue=%str(1=1)
|
%macro mf_abort(mac=mf_abort.sas, msg=, iftrue=%str(1=1)
|
||||||
)/*/STORE SOURCE*/;
|
)/des='ungraceful abort' /*STORE SOURCE*/;
|
||||||
|
|
||||||
%if not(%eval(%unquote(&iftrue))) %then %return;
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
||||||
|
|
||||||
@@ -24,4 +24,4 @@
|
|||||||
|
|
||||||
%mend mf_abort;
|
%mend mf_abort;
|
||||||
|
|
||||||
/** @endcond */
|
/** @endcond */
|
||||||
|
|||||||
@@ -30,4 +30,4 @@
|
|||||||
0
|
0
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mf_existfileref;
|
%mend mf_existfileref;
|
||||||
|
|||||||
@@ -25,13 +25,17 @@
|
|||||||
%local dsid rc;
|
%local dsid rc;
|
||||||
%let dsid=%sysfunc(open(&libds,is));
|
%let dsid=%sysfunc(open(&libds,is));
|
||||||
|
|
||||||
%if &dsid=0 or %length(&var)=0 %then %do;
|
%if &dsid=0 %then %do;
|
||||||
%put %sysfunc(sysmsg());
|
%put %sysfunc(sysmsg());
|
||||||
0
|
0
|
||||||
|
%end;
|
||||||
|
%else %if %length(&var)=0 %then %do;
|
||||||
|
0
|
||||||
|
%let rc=%sysfunc(close(&dsid));
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
%sysfunc(varnum(&dsid,&var))
|
%sysfunc(varnum(&dsid,&var))
|
||||||
%let rc=%sysfunc(close(&dsid));
|
%let rc=%sysfunc(close(&dsid));
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mf_existvar;
|
%mend mf_existvar;
|
||||||
|
|||||||
37
base/mf_getgitbranch.sas
Normal file
37
base/mf_getgitbranch.sas
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Retrieves the current branch from a local GIT repo
|
||||||
|
@details In a local git repository, the current branch is always available in
|
||||||
|
the `.git/HEAD` file in a format like this: `ref: refs/heads/master`
|
||||||
|
|
||||||
|
This macro simply reads the file and returns the last word (eg `master`).
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
|
||||||
|
%let gitdir=%sysfunc(pathname(work))/core;
|
||||||
|
%let repo=https://github.com/sasjs/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(&repo,&gitdir));
|
||||||
|
|
||||||
|
%put The current branch is %mf_getgitbranch(&gitdir);
|
||||||
|
|
||||||
|
@param [in] gitdir The directory containing the GIT repository
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_readfile.sas
|
||||||
|
|
||||||
|
<h4> Related Macros </h4>
|
||||||
|
@li mp_gitadd.sas
|
||||||
|
@li mp_gitlog.sas
|
||||||
|
@li mp_gitreleaseinfo.sas
|
||||||
|
@li mp_gitstatus.sas
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mf_getgitbranch(gitdir
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
|
%scan(%mf_readfile(&gitdir/.git/HEAD),-1)
|
||||||
|
|
||||||
|
%mend mf_getgitbranch;
|
||||||
63
base/mf_readfile.sas
Normal file
63
base/mf_readfile.sas
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Reads the first line of a file using pure macro
|
||||||
|
@details Reads the first line of a file and returns it. Future versions may
|
||||||
|
read each line into a macro variable array.
|
||||||
|
|
||||||
|
Generally, reading data into macro variables is not great as certain
|
||||||
|
nonprintable characters (such as CR, LF) may be dropped in the conversion.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
%mf_writefile(&sasjswork/myfile.txt,l1=some content,l2=more content)
|
||||||
|
|
||||||
|
%put %mf_readfile(&sasjswork/myfile.txt);
|
||||||
|
|
||||||
|
|
||||||
|
@param [in] fpath Full path to file to be read
|
||||||
|
|
||||||
|
<h4> Related Macros </h4>
|
||||||
|
@li mf_deletefile.sas
|
||||||
|
@li mf_writefile.sas
|
||||||
|
@li mf_readfile.test.sas
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
**/
|
||||||
|
/** @cond */
|
||||||
|
|
||||||
|
%macro mf_readfile(fpath
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
%local fref rc fid fcontent;
|
||||||
|
|
||||||
|
/* check file exists */
|
||||||
|
%if %sysfunc(filename(fref,&fpath)) ne 0 %then %do;
|
||||||
|
%put &=fref &=fpath;
|
||||||
|
%put %str(ERR)OR: %sysfunc(sysmsg());
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%let fid=%sysfunc(fopen(&fref,I));
|
||||||
|
|
||||||
|
%if &fid=0 %then %do;
|
||||||
|
%put %str(ERR)OR: %sysfunc(sysmsg());
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%if %sysfunc(fread(&fid)) = 0 %then %do;
|
||||||
|
%let rc=%sysfunc(fget(&fid,fcontent,65534));
|
||||||
|
&fcontent
|
||||||
|
%end;
|
||||||
|
|
||||||
|
/*
|
||||||
|
%do %while(%sysfunc(fread(&fid)) = 0);
|
||||||
|
%let rc=%sysfunc(fget(&fid,fcontent,65534));
|
||||||
|
&fcontent
|
||||||
|
%end;
|
||||||
|
*/
|
||||||
|
|
||||||
|
%let rc=%sysfunc(fclose(&fid));
|
||||||
|
%let rc=%sysfunc(filename(&fref));
|
||||||
|
|
||||||
|
%mend mf_readfile;
|
||||||
|
/** @endcond */
|
||||||
@@ -225,15 +225,51 @@ and %superq(SYSPROCESSNAME) ne %str(Compute Server)
|
|||||||
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
||||||
put ',"_PROGRAM" : ' _PROGRAM ;
|
put ',"_PROGRAM" : ' _PROGRAM ;
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
syserrortext=cats('"',tranwrd(symget('syserrortext'),'"','\"'),'"');
|
syserrortext=cats(symget('syserrortext'));
|
||||||
put ",""SYSERRORTEXT"" : " syserrortext;
|
if findc(syserrortext,'"\'!!'0A0D09000E0F010210111A'x) then do;
|
||||||
|
syserrortext='"'!!trim(
|
||||||
|
prxchange('s/"/\\"/',-1, /* double quote */
|
||||||
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
||||||
|
prxchange('s/\x0D/\r/',-1, /* carriage return */
|
||||||
|
prxchange('s/\x09/\\t/',-1, /* tab */
|
||||||
|
prxchange('s/\x00/\\u0000/',-1, /* NUL */
|
||||||
|
prxchange('s/\x0E/\\u000E/',-1, /* SS */
|
||||||
|
prxchange('s/\x0F/\\u000F/',-1, /* SF */
|
||||||
|
prxchange('s/\x01/\\u0001/',-1, /* SOH */
|
||||||
|
prxchange('s/\x02/\\u0002/',-1, /* STX */
|
||||||
|
prxchange('s/\x10/\\u0010/',-1, /* DLE */
|
||||||
|
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
|
||||||
|
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
|
||||||
|
prxchange('s/\\/\\\\/',-1,syserrortext)
|
||||||
|
)))))))))))))!!'"';
|
||||||
|
end;
|
||||||
|
else syserrortext=cats('"',syserrortext,'"');
|
||||||
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
||||||
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
||||||
put ",""SYSSCPL"" : ""&sysscpl"" ";
|
put ",""SYSSCPL"" : ""&sysscpl"" ";
|
||||||
put ",""SYSSITE"" : ""&syssite"" ";
|
put ",""SYSSITE"" : ""&syssite"" ";
|
||||||
sysvlong=quote(trim(symget('sysvlong')));
|
sysvlong=quote(trim(symget('sysvlong')));
|
||||||
put ',"SYSVLONG" : ' sysvlong;
|
put ',"SYSVLONG" : ' sysvlong;
|
||||||
syswarningtext=cats('"',tranwrd(symget('syswarningtext'),'"','\"'),'"');
|
syswarningtext=cats(symget('syswarningtext'));
|
||||||
|
if findc(syswarningtext,'"\'!!'0A0D09000E0F010210111A'x) then do;
|
||||||
|
syswarningtext='"'!!trim(
|
||||||
|
prxchange('s/"/\\"/',-1, /* double quote */
|
||||||
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
||||||
|
prxchange('s/\x0D/\r/',-1, /* carriage return */
|
||||||
|
prxchange('s/\x09/\\t/',-1, /* tab */
|
||||||
|
prxchange('s/\x00/\\u0000/',-1, /* NUL */
|
||||||
|
prxchange('s/\x0E/\\u000E/',-1, /* SS */
|
||||||
|
prxchange('s/\x0F/\\u000F/',-1, /* SF */
|
||||||
|
prxchange('s/\x01/\\u0001/',-1, /* SOH */
|
||||||
|
prxchange('s/\x02/\\u0002/',-1, /* STX */
|
||||||
|
prxchange('s/\x10/\\u0010/',-1, /* DLE */
|
||||||
|
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
|
||||||
|
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
|
||||||
|
prxchange('s/\\/\\\\/',-1,syswarningtext)
|
||||||
|
)))))))))))))!!'"';
|
||||||
|
end;
|
||||||
|
else syswarningtext=cats('"',syswarningtext,'"');
|
||||||
put ",""SYSWARNINGTEXT"" : " syswarningtext;
|
put ",""SYSWARNINGTEXT"" : " syswarningtext;
|
||||||
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
||||||
put "}" ;
|
put "}" ;
|
||||||
|
|||||||
95
base/mp_aligndecimal.sas
Normal file
95
base/mp_aligndecimal.sas
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Apply leading blanks to align numbers vertically in a char variable
|
||||||
|
@details This is particularly useful when storing numbers (as character) that
|
||||||
|
need to be sorted.
|
||||||
|
|
||||||
|
It works by splitting the number left and right of the decimal place, and
|
||||||
|
aligning it accordingly. A temporary variable is created as part of this
|
||||||
|
process (which is automatically dropped)
|
||||||
|
|
||||||
|
The macro can be used only in data step, eg as follows:
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
length myvar $50;
|
||||||
|
do i=1 to 1000 by 50;
|
||||||
|
if mod(i,2)=0 then j=ranuni(0)*i*100;
|
||||||
|
else j=i*100;
|
||||||
|
|
||||||
|
%mp_aligndecimal(myvar,width=7)
|
||||||
|
|
||||||
|
leading_spaces=length(myvar)-length(cats(myvar));
|
||||||
|
putlog +leading_spaces myvar;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
The generated code will look something like this:
|
||||||
|
|
||||||
|
length aligndp4e49996 $7;
|
||||||
|
if index(myvar,'.') then do;
|
||||||
|
aligndp4e49996=cats(scan(myvar,1,'.'));
|
||||||
|
aligndp4e49996=right(aligndp4e49996);
|
||||||
|
myvar=aligndp4e49996!!'.'!!cats(scan(myvar,2,'.'));
|
||||||
|
end;
|
||||||
|
else do;
|
||||||
|
aligndp4e49996=myvar;
|
||||||
|
aligndp4e49996=right(aligndp4e49996);
|
||||||
|
myvar=aligndp4e49996;
|
||||||
|
end;
|
||||||
|
drop aligndp4e49996;
|
||||||
|
|
||||||
|
Results (myvar variable):
|
||||||
|
|
||||||
|
0.7683559324
|
||||||
|
122.8232796
|
||||||
|
99419.50552
|
||||||
|
42938.5143414
|
||||||
|
763.3799189
|
||||||
|
15170.606073
|
||||||
|
15083.285773
|
||||||
|
85443.198707
|
||||||
|
2022999.2251
|
||||||
|
12038.658867
|
||||||
|
1350582.6734
|
||||||
|
52777.258221
|
||||||
|
11723.347628
|
||||||
|
33101.268376
|
||||||
|
6181622.8603
|
||||||
|
7390614.0669
|
||||||
|
73384.537893
|
||||||
|
1788362.1016
|
||||||
|
2774586.2219
|
||||||
|
7998580.8415
|
||||||
|
|
||||||
|
|
||||||
|
@param var The (data step, character) variable to modify
|
||||||
|
@param width= (8) The number of characters BEFORE the decimal point
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
|
||||||
|
<h4> Related Programs </h4>
|
||||||
|
@li mp_aligndecimal.test.sas
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_aligndecimal(var,width=8);
|
||||||
|
|
||||||
|
%local tmpvar;
|
||||||
|
%let tmpvar=%mf_getuniquename(prefix=aligndp);
|
||||||
|
length &tmpvar $&width;
|
||||||
|
if index(&var,'.') then do;
|
||||||
|
&tmpvar=cats(scan(&var,1,'.'));
|
||||||
|
&tmpvar=right(&tmpvar);
|
||||||
|
&var=&tmpvar!!'.'!!cats(scan(&var,2,'.'));
|
||||||
|
end;
|
||||||
|
else do;
|
||||||
|
&tmpvar=cats(&var);
|
||||||
|
&tmpvar=right(&tmpvar);
|
||||||
|
&var=&tmpvar;
|
||||||
|
end;
|
||||||
|
drop &tmpvar;
|
||||||
|
|
||||||
|
%mend mp_aligndecimal;
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
results. If it does not exist, it will be created, with the following format:
|
results. If it does not exist, it will be created, with the following format:
|
||||||
|TEST_DESCRIPTION:$256|TEST_RESULT:$4|TEST_COMMENTS:$256|
|
|TEST_DESCRIPTION:$256|TEST_RESULT:$4|TEST_COMMENTS:$256|
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|User Provided description|PASS|Column &inds contained ALL columns|
|
|User Provided description|PASS|Dataset &inds contained ALL columns|
|
||||||
|
|
||||||
@version 9.2
|
@version 9.2
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
results. If it does not exist, it will be created, with the following format:
|
results. If it does not exist, it will be created, with the following format:
|
||||||
|TEST_DESCRIPTION:$256|TEST_RESULT:$4|TEST_COMMENTS:$256|
|
|TEST_DESCRIPTION:$256|TEST_RESULT:$4|TEST_COMMENTS:$256|
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|User Provided description|PASS|Column &inds contained ALL columns|
|
|User Provided description|PASS|Dataset &inds contained ALL columns|
|
||||||
|
|
||||||
|
|
||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
@param [in] test= (ALLVALS) The test to apply. Valid values are:
|
@param [in] test= (ALLVALS) The test to apply. Valid values are:
|
||||||
@li ALLVALS - Test is a PASS if ALL values have a match in checkvals
|
@li ALLVALS - Test is a PASS if ALL values have a match in checkvals
|
||||||
@li ANYVAL - Test is a PASS if at least 1 value has a match in checkvals
|
@li ANYVAL - Test is a PASS if at least 1 value has a match in checkvals
|
||||||
|
@li NOVAL - Test is a PASS if there are NO matches in checkvals
|
||||||
@param [out] outds= (work.test_results) The output dataset to contain the
|
@param [out] outds= (work.test_results) The output dataset to contain the
|
||||||
results. If it does not exist, it will be created, with the following format:
|
results. If it does not exist, it will be created, with the following format:
|
||||||
|TEST_DESCRIPTION:$256|TEST_RESULT:$4|TEST_COMMENTS:$256|
|
|TEST_DESCRIPTION:$256|TEST_RESULT:$4|TEST_COMMENTS:$256|
|
||||||
@@ -97,7 +98,7 @@
|
|||||||
|
|
||||||
%let test=%upcase(&test);
|
%let test=%upcase(&test);
|
||||||
|
|
||||||
%if &test ne ALLVALS and &test ne ANYVAL %then %do;
|
%if &test ne ALLVALS and &test ne ANYVAL and &test ne NOVAL %then %do;
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
mac=&sysmacroname,
|
mac=&sysmacroname,
|
||||||
msg=%str(Invalid test - &test)
|
msg=%str(Invalid test - &test)
|
||||||
@@ -108,12 +109,12 @@
|
|||||||
%let result=-1;
|
%let result=-1;
|
||||||
%let orig=-1;
|
%let orig=-1;
|
||||||
proc sql noprint;
|
proc sql noprint;
|
||||||
select count(*) into: result
|
select count(*) into: result trimmed
|
||||||
from &lib..&ds
|
from &lib..&ds
|
||||||
where &col not in (
|
where &col not in (
|
||||||
select &ccol from &clib..&cds
|
select &ccol from &clib..&cds
|
||||||
);
|
);
|
||||||
select count(*) into: orig from &lib..&ds;
|
select count(*) into: orig trimmed from &lib..&ds;
|
||||||
quit;
|
quit;
|
||||||
|
|
||||||
%local notfound tmp1 tmp2;
|
%local notfound tmp1 tmp2;
|
||||||
@@ -145,7 +146,7 @@
|
|||||||
length test_description $256 test_result $4 test_comments $256;
|
length test_description $256 test_result $4 test_comments $256;
|
||||||
test_description=symget('desc');
|
test_description=symget('desc');
|
||||||
test_result='FAIL';
|
test_result='FAIL';
|
||||||
test_comments="&sysmacroname: &lib..&ds..&col has &result values "
|
test_comments="&sysmacroname: &lib..&ds..&col has &result/&orig values "
|
||||||
!!"not in &clib..&cds..&ccol.. First 10 vals:"!!symget('notfound');
|
!!"not in &clib..&cds..&ccol.. First 10 vals:"!!symget('notfound');
|
||||||
%if &test=ANYVAL %then %do;
|
%if &test=ANYVAL %then %do;
|
||||||
if &result < &orig then test_result='PASS';
|
if &result < &orig then test_result='PASS';
|
||||||
@@ -153,6 +154,9 @@
|
|||||||
%else %if &test=ALLVALS %then %do;
|
%else %if &test=ALLVALS %then %do;
|
||||||
if &result=0 then test_result='PASS';
|
if &result=0 then test_result='PASS';
|
||||||
%end;
|
%end;
|
||||||
|
%else %if &test=NOVAL %then %do;
|
||||||
|
if &result=&orig then test_result='PASS';
|
||||||
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
test_comments="&sysmacroname: Unsatisfied test condition - &test";
|
test_comments="&sysmacroname: Unsatisfied test condition - &test";
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mddl_sas_cntlout.sas
|
@li mddl_sas_cntlout.sas
|
||||||
@li mf_getuniquename.sas
|
@li mf_getuniquename.sas
|
||||||
|
@li mp_aligndecimal.sas
|
||||||
|
|
||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
@li mf_getvarformat.sas
|
@li mf_getvarformat.sas
|
||||||
@@ -66,16 +67,24 @@ proc format lib=&libcat cntlout=&cntlds;
|
|||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
data &cntlout;
|
data &cntlout/nonote2err;
|
||||||
if 0 then set &ddlds;
|
if 0 then set &ddlds;
|
||||||
set &cntlds;
|
set &cntlds;
|
||||||
if type="N" then do;
|
by type fmtname notsorted;
|
||||||
start=cats(start);
|
|
||||||
end=cats(end);
|
/* align the numeric values to avoid overlapping ranges */
|
||||||
|
if type in ("I","N") then do;
|
||||||
|
%mp_aligndecimal(start,width=16)
|
||||||
|
%mp_aligndecimal(end,width=16)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
/* create row marker. Data cannot be sorted without it! */
|
||||||
|
if first.fmtname then fmtrow=0;
|
||||||
|
fmtrow+1;
|
||||||
|
|
||||||
run;
|
run;
|
||||||
proc sort;
|
proc sort;
|
||||||
by fmtname start;
|
by type fmtname fmtrow;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
proc sql;
|
proc sql;
|
||||||
|
|||||||
@@ -101,8 +101,7 @@ data &out_ds(compress=no
|
|||||||
if did=0 then do;
|
if did=0 then do;
|
||||||
putlog "NOTE: This directory is empty, or does not exist - &path";
|
putlog "NOTE: This directory is empty, or does not exist - &path";
|
||||||
msg=sysmsg();
|
msg=sysmsg();
|
||||||
put msg;
|
put (_all_)(=);
|
||||||
put _all_;
|
|
||||||
stop;
|
stop;
|
||||||
end;
|
end;
|
||||||
/* attribute is OS-dependent - could be "Directory" or "Directory Name" */
|
/* attribute is OS-dependent - could be "Directory" or "Directory Name" */
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ run;
|
|||||||
options ps=max lrecl=max;
|
options ps=max lrecl=max;
|
||||||
data _null_;
|
data _null_;
|
||||||
infile &outref;
|
infile &outref;
|
||||||
|
if _n_=1 then putlog "# &libds" /;
|
||||||
input;
|
input;
|
||||||
putlog _infile_;
|
putlog _infile_;
|
||||||
run;
|
run;
|
||||||
|
|||||||
45
base/mp_gitadd.sas
Normal file
45
base/mp_gitadd.sas
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Stages files in a GIT repo
|
||||||
|
@details Uses the output dataset from mp_gitstatus.sas to determine the files
|
||||||
|
that should be staged.
|
||||||
|
|
||||||
|
If `STAGED ne "TRUE"` then the file is staged.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
%let dir=%sysfunc(pathname(work))/core;
|
||||||
|
%let repo=https://github.com/sasjs/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(&repo,&dir));
|
||||||
|
%mf_writefile(&dir/somefile.txt,l1=some content)
|
||||||
|
%mf_deletefile(&dir/package.json)
|
||||||
|
%mp_gitstatus(&dir,outds=work.gitstatus)
|
||||||
|
|
||||||
|
%mp_gitadd(&dir,inds=work.gitstatus)
|
||||||
|
|
||||||
|
@param [in] gitdir The directory containing the GIT repository
|
||||||
|
@param [in] inds= (work.mp_gitadd) The input dataset with the list of files
|
||||||
|
to stage. Will accept the output from mp_gitstatus(), else just use a table
|
||||||
|
with the following columns:
|
||||||
|
@li path $1024 - relative path to the file in the repo
|
||||||
|
@li staged $32 - whether the file is staged (TRUE or FALSE)
|
||||||
|
@li status $64 - either new, deleted, or modified
|
||||||
|
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li mp_gitadd.test.sas
|
||||||
|
@li mp_gitstatus.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_gitadd(gitdir,inds=work.mp_gitadd,mdebug=0);
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
set &inds;
|
||||||
|
if STAGED ne "TRUE";
|
||||||
|
rc=git_index_add("&gitdir",cats(path),status);
|
||||||
|
if rc ne 0 or &mdebug=1 then put rc=;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mend mp_gitadd;
|
||||||
104
base/mp_gitlog.sas
Normal file
104
base/mp_gitlog.sas
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Creates a dataset with the commit history of a local repository
|
||||||
|
@details Returns the commit history from a local repository. The name of the
|
||||||
|
branch is also returned.
|
||||||
|
|
||||||
|
More details here:
|
||||||
|
https://documentation.sas.com/doc/ko/pgmsascdc/v_033/lefunctionsref/n1qo5miyvry1nen111js203hlwrh.htm
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
%let gitdir=%sysfunc(pathname(work))/core;
|
||||||
|
%let repo=https://github.com/sasjs/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(&repo,&dir));
|
||||||
|
|
||||||
|
%mp_gitlog(&gitdir,outds=work.mp_gitlog)
|
||||||
|
|
||||||
|
@param [in] gitdir The directory containing the GIT repository
|
||||||
|
@param [in] filter= (BRANCHONLY) To return only the commits for the current
|
||||||
|
branch, use BRANCHONLY (the default). Anything else will return the entire
|
||||||
|
commit history.
|
||||||
|
@param [out] outds= (work.mp_gitlog) The output dataset to create.
|
||||||
|
All vars are $128 except `message` which is $4000.
|
||||||
|
@li author returns the author who submitted the commit.
|
||||||
|
@li children_ids returns a list of the children commit IDs
|
||||||
|
@li committer returns the name of the committer.
|
||||||
|
@li committer_email returns the email of the committer.
|
||||||
|
@li email returns the email of the commit author.
|
||||||
|
@li id returns the commit ID of the commit object.
|
||||||
|
@li in_current_branch returns "TRUE" or "FALSE" to indicate if the commit is
|
||||||
|
in the current branch.
|
||||||
|
@li message returns the commit message.
|
||||||
|
@li parent_ids returns a list of the parent commit IDs.
|
||||||
|
@li stash returns "TRUE" or "FALSE" to indicate if the commit is a stash
|
||||||
|
commit.
|
||||||
|
@li time returns the time of the commit as numeric string
|
||||||
|
@li commit_time_num time of the commit as numeric SAS datetime
|
||||||
|
@li commit_time_str the commit_time_num variable cast as string
|
||||||
|
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] nobs= (0) Set to an integer greater than 0 to restrict the number
|
||||||
|
of rows returned
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getgitbranch.sas
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li mp_gitadd.sas
|
||||||
|
@li mp_gitreleaseinfo.sas
|
||||||
|
@li mp_gitstatus.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_gitlog(gitdir,outds=work.mp_gitlog,mdebug=0,filter=BRANCHONLY,nobs=0);
|
||||||
|
|
||||||
|
%local varlist i var;
|
||||||
|
%let varlist=author children_ids committer committer_email email id
|
||||||
|
in_current_branch parent_ids stash time ;
|
||||||
|
|
||||||
|
data &outds;
|
||||||
|
LENGTH gitdir branch $ 1024 message $4000 &varlist $128 commit_time_num 8.
|
||||||
|
commit_time_str $32;
|
||||||
|
call missing (of _all_);
|
||||||
|
branch="%mf_getgitbranch(&gitdir)";
|
||||||
|
gitdir=symget('gitdir');
|
||||||
|
rc=git_status_free(trim(gitdir));
|
||||||
|
if rc=-1 then do;
|
||||||
|
put "The libgit2 library is unavailable and no Git operations can be used.";
|
||||||
|
put "See: https://stackoverflow.com/questions/74082874";
|
||||||
|
stop;
|
||||||
|
end;
|
||||||
|
else if rc=-2 then do;
|
||||||
|
put "The libgit2 library is available, but the status function failed.";
|
||||||
|
put "See the log for details.";
|
||||||
|
stop;
|
||||||
|
end;
|
||||||
|
entries=git_commit_log(trim(gitdir));
|
||||||
|
do n=1 to entries;
|
||||||
|
|
||||||
|
%do i=1 %to %sysfunc(countw(&varlist message));
|
||||||
|
%let var=%scan(&varlist message,&i,%str( ));
|
||||||
|
rc=git_commit_get(n,trim(gitdir),"&var",&var);
|
||||||
|
%end;
|
||||||
|
/* convert unix time to SAS time - https://4gl.uk/corelink0 */
|
||||||
|
/* Number of seconds between 01JAN1960 and 01JAN1970: 315619200 */
|
||||||
|
format commit_time_num datetime19.;
|
||||||
|
commit_time_num=sum(input(cats(time),best.),315619200);
|
||||||
|
commit_time_str=put(commit_time_num,datetime19.);
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
putlog (_all_)(=);
|
||||||
|
%end;
|
||||||
|
if "&filter"="BRANCHONLY" then do;
|
||||||
|
if cats(in_current_branch)='TRUE' then output;
|
||||||
|
end;
|
||||||
|
else output;
|
||||||
|
%if &nobs>0 %then %do;
|
||||||
|
if n ge &nobs then stop;
|
||||||
|
%end;
|
||||||
|
end;
|
||||||
|
rc=git_commit_free(trim(gitdir));
|
||||||
|
keep gitdir branch &varlist message time commit_time_num commit_time_str;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mend mp_gitlog;
|
||||||
74
base/mp_gitreleaseinfo.sas
Normal file
74
base/mp_gitreleaseinfo.sas
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Pulls latest release info from a GIT repository
|
||||||
|
@details Useful for grabbing the latest version number or other attributes
|
||||||
|
from a GIT server. Supported providers are GitLab and GitHub. Pull requests
|
||||||
|
are welcome if you'd like to see additional providers!
|
||||||
|
|
||||||
|
Note that each provider provides slightly different JSON output. Therefore
|
||||||
|
the macro simply extracts the JSON and assigns the libname (using the JSON
|
||||||
|
engine).
|
||||||
|
|
||||||
|
Example usage (eg, to grab latest release version from github):
|
||||||
|
|
||||||
|
%mp_gitreleaseinfo(GITHUB,sasjs/core,outlib=mylibref)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
set mylibref.root;
|
||||||
|
putlog TAG_NAME=;
|
||||||
|
run;
|
||||||
|
|
||||||
|
@param [in] provider The GIT provider for the release info. Accepted values:
|
||||||
|
@li GITLAB
|
||||||
|
@li GITHUB - Tables include root, assets, author, alldata
|
||||||
|
@param [in] project The link to the repository. This has different formats
|
||||||
|
depending on the vendor:
|
||||||
|
@li GITHUB - org/repo, eg sasjs/core
|
||||||
|
@li GITLAB - project, eg 1343223
|
||||||
|
@param [in] server= (0) If your repo is self-hosted, then provide the domain
|
||||||
|
here. Otherwise it will default to the provider domain (eg gitlab.com).
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [out] outlib= (GITREL) The JSON-engine libref to be created, which will
|
||||||
|
point at the returned JSON
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquefileref.sas
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li mp_gitreleaseinfo.test.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_gitreleaseinfo(provider,project,server=0,outlib=GITREL,mdebug=0);
|
||||||
|
%local url fref;
|
||||||
|
|
||||||
|
%let provider=%upcase(&provider);
|
||||||
|
|
||||||
|
%if &provider=GITHUB %then %do;
|
||||||
|
%if "&server"="0" %then %let server=https://api.github.com;
|
||||||
|
%let url=&server/repos/&project/releases/latest;
|
||||||
|
%end;
|
||||||
|
%else %if &provider=GITLAB %then %do;
|
||||||
|
%if "&server"="0" %then %let server=https://gitlab.com;
|
||||||
|
%let url=&server/api/v4/projects/&project/releases;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%let fref=%mf_getuniquefileref();
|
||||||
|
|
||||||
|
proc http method='GET' out=&fref url="&url";
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
debug level = 3;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
libname &outlib JSON fileref=&fref;
|
||||||
|
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
infile &fref;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend mp_gitreleaseinfo;
|
||||||
67
base/mp_gitstatus.sas
Normal file
67
base/mp_gitstatus.sas
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Creates a dataset with the output from `GIT_STATUS()`
|
||||||
|
@details Uses `git_status()` to fetch the number of changed files, then
|
||||||
|
iterates with `git_status_get()`, inserting all attributes into an output
|
||||||
|
dataset.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
%let dir=%sysfunc(pathname(work))/core;
|
||||||
|
%let repo=https://github.com/sasjs/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(&repo,&dir));
|
||||||
|
%mf_writefile(&dir/somefile.txt,l1=some content)
|
||||||
|
%mf_deletefile(&dir/package.json)
|
||||||
|
|
||||||
|
%mp_gitstatus(&dir,outds=work.gitstatus)
|
||||||
|
|
||||||
|
More info on these functions is in this [helpful paper]
|
||||||
|
(https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3057-2019.pdf)
|
||||||
|
by Danny Zimmerman.
|
||||||
|
|
||||||
|
@param [in] gitdir The directory containing the GIT repository
|
||||||
|
@param [out] outds= (work.git_status) The output dataset to create. Vars:
|
||||||
|
@li gitdir $1024 - directory of repo
|
||||||
|
@li path $1024 - relative path to the file in the repo
|
||||||
|
@li staged $32 - whether the file is staged (TRUE or FALSE)
|
||||||
|
@li status $64 - either new, deleted, or modified
|
||||||
|
@li cnt - number of files
|
||||||
|
@li n - the "nth" file in the list from git_status()
|
||||||
|
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li mp_gitstatus.test.sas
|
||||||
|
@li mp_gitadd.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_gitstatus(gitdir,outds=work.mp_gitstatus,mdebug=0);
|
||||||
|
|
||||||
|
data &outds;
|
||||||
|
LENGTH gitdir path $ 1024 STATUS $ 64 STAGED $ 32;
|
||||||
|
call missing (of _all_);
|
||||||
|
gitdir=symget('gitdir');
|
||||||
|
cnt=git_status(trim(gitdir));
|
||||||
|
if cnt=-1 then do;
|
||||||
|
put "The libgit2 library is unavailable and no Git operations can be used.";
|
||||||
|
put "See: https://stackoverflow.com/questions/74082874";
|
||||||
|
end;
|
||||||
|
else if cnt=-2 then do;
|
||||||
|
put "The libgit2 library is available, but the status function failed.";
|
||||||
|
put "See the log for details.";
|
||||||
|
end;
|
||||||
|
else do n=1 to cnt;
|
||||||
|
rc=GIT_STATUS_GET(n,gitdir,'PATH',path);
|
||||||
|
rc=GIT_STATUS_GET(n,gitdir,'STAGED',staged);
|
||||||
|
rc=GIT_STATUS_GET(n,gitdir,'STATUS',status);
|
||||||
|
output;
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
putlog (_all_)(=);
|
||||||
|
%end;
|
||||||
|
end;
|
||||||
|
rc=git_status_free(trim(gitdir));
|
||||||
|
drop rc cnt;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mend mp_gitstatus;
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
create a hash for each directory also.
|
create a hash for each directory also.
|
||||||
|
|
||||||
This makes use of the new `hashing_file()` and `hashing` functions, available
|
This makes use of the new `hashing_file()` and `hashing` functions, available
|
||||||
since 9.4m6. Interestingly, these can even be used in pure macro, eg:
|
since 9.4m6. Interestingly, those functions can be used in pure macro, eg:
|
||||||
|
|
||||||
%put %sysfunc(hashing_file(md5,/path/to/file.blob,0));
|
%put %sysfunc(hashing_file(md5,/path/to/file.blob,0));
|
||||||
|
|
||||||
@@ -30,8 +30,9 @@
|
|||||||
@li If a folder contains other folders, start from the bottom of the tree -
|
@li If a folder contains other folders, start from the bottom of the tree -
|
||||||
the folder hashes cascade upwards so you know immediately if there is a
|
the folder hashes cascade upwards so you know immediately if there is a
|
||||||
change in a sub/sub directory
|
change in a sub/sub directory
|
||||||
@li If the folder has no content (empty) then it is ignored. No hash created.
|
@li If a subfolder has no content (empty) then it is ignored. No hash created.
|
||||||
@li If the file is empty, it is also ignored / no hash created.
|
@li If the file is empty, it is also ignored / no hash created.
|
||||||
|
@li If the target directory (&inloc) is empty, &outds will also be empty
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_dirlist.sas
|
@li mp_dirlist.sas
|
||||||
@@ -72,7 +73,7 @@
|
|||||||
iftrue=%str(1=1)
|
iftrue=%str(1=1)
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%local curlevel tempds ;
|
%local curlevel tempds maxlevel;
|
||||||
|
|
||||||
%if not(%eval(%unquote(&iftrue))) %then %return;
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
||||||
|
|
||||||
@@ -108,6 +109,7 @@ proc sort data=&outds ;
|
|||||||
by descending level directory file_path;
|
by descending level directory file_path;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
%let maxlevel=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set &outds;
|
set &outds;
|
||||||
call symputx('maxlevel',level,'l');
|
call symputx('maxlevel',level,'l');
|
||||||
|
|||||||
@@ -34,10 +34,10 @@
|
|||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages and preserve outputs
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages and preserve outputs
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mddl_sas_cntlout.sas
|
|
||||||
@li mf_getuniquename.sas
|
@li mf_getuniquename.sas
|
||||||
@li mf_nobs.sas
|
@li mf_nobs.sas
|
||||||
@li mp_abort.sas
|
@li mp_abort.sas
|
||||||
|
@li mp_aligndecimal.sas
|
||||||
@li mp_cntlout.sas
|
@li mp_cntlout.sas
|
||||||
@li mp_lockanytable.sas
|
@li mp_lockanytable.sas
|
||||||
@li mp_storediffs.sas
|
@li mp_storediffs.sas
|
||||||
@@ -45,7 +45,8 @@
|
|||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
@li mddl_dc_difftable.sas
|
@li mddl_dc_difftable.sas
|
||||||
@li mddl_dc_locktable.sas
|
@li mddl_dc_locktable.sas
|
||||||
@li mp_loadformat.test.sas
|
@li mp_loadformat.test.1.sas
|
||||||
|
@li mp_loadformat.test.2.sas
|
||||||
@li mp_lockanytable.sas
|
@li mp_lockanytable.sas
|
||||||
@li mp_stackdiffs.sas
|
@li mp_stackdiffs.sas
|
||||||
|
|
||||||
@@ -78,13 +79,6 @@
|
|||||||
%let &var=%upcase(&prefix._&var);
|
%let &var=%upcase(&prefix._&var);
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
/*
|
|
||||||
format values can be up to 32767 wide. SQL joins on such a wide column can
|
|
||||||
cause buffer issues. Update ibufsize and reset at the end.
|
|
||||||
*/
|
|
||||||
%let ibufsize=%sysfunc(getoption(ibufsize));
|
|
||||||
options ibufsize=32767 ;
|
|
||||||
|
|
||||||
/* in DC, format catalogs maybe specified in the libds with a -FC extension */
|
/* in DC, format catalogs maybe specified in the libds with a -FC extension */
|
||||||
%let libcat=%scan(&libcat,1,-);
|
%let libcat=%scan(&libcat,1,-);
|
||||||
|
|
||||||
@@ -134,29 +128,62 @@ run;
|
|||||||
* First, extract only relevant formats from the catalog
|
* First, extract only relevant formats from the catalog
|
||||||
*/
|
*/
|
||||||
proc sql noprint;
|
proc sql noprint;
|
||||||
select distinct upcase(fmtname) into: fmtlist separated by ' ' from &libds;
|
select distinct
|
||||||
|
case
|
||||||
|
when type='N' then upcase(fmtname)
|
||||||
|
when type='C' then cats('$',upcase(fmtname))
|
||||||
|
when type='I' then cats('@',upcase(fmtname))
|
||||||
|
when type='J' then cats('@$',upcase(fmtname))
|
||||||
|
else "&sysmacroname:UNHANDLED"
|
||||||
|
end
|
||||||
|
into: fmtlist separated by ' '
|
||||||
|
from &libds;
|
||||||
|
|
||||||
%mp_cntlout(libcat=&libcat,fmtlist=&fmtlist,cntlout=&base_fmts)
|
%mp_cntlout(libcat=&libcat,fmtlist=&fmtlist,cntlout=&base_fmts)
|
||||||
|
|
||||||
|
/* get a hash of the row */
|
||||||
|
%local cvars nvars;
|
||||||
|
%let cvars=TYPE FMTNAME START END LABEL PREFIX FILL SEXCL EEXCL HLO DECSEP
|
||||||
|
DIG3SEP DATATYPE LANGUAGE;
|
||||||
|
%let nvars=FMTROW MIN MAX DEFAULT LENGTH FUZZ MULT NOEDIT;
|
||||||
|
data &base_fmts/note2err;
|
||||||
|
set &base_fmts;
|
||||||
|
fmthash=%mp_md5(cvars=&cvars, nvars=&nvars);
|
||||||
|
run;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure input table and base_formats have consistent lengths and types
|
* Ensure input table and base_formats have consistent lengths and types
|
||||||
*/
|
*/
|
||||||
%mddl_sas_cntlout(libds=&template)
|
data &inlibds/nonote2err;
|
||||||
data &inlibds;
|
length &delete_col $3 FMTROW 8 start end label $32767;
|
||||||
length &delete_col $3;
|
if 0 then set &base_fmts;
|
||||||
if 0 then set &template;
|
|
||||||
set &libds;
|
set &libds;
|
||||||
|
by type fmtname notsorted;
|
||||||
if &delete_col='' then &delete_col='No';
|
if &delete_col='' then &delete_col='No';
|
||||||
fmtname=upcase(fmtname);
|
fmtname=upcase(fmtname);
|
||||||
|
type=upcase(type);
|
||||||
if missing(type) then do;
|
if missing(type) then do;
|
||||||
if substr(fmtname,1,1)='$' then type='C';
|
if substr(fmtname,1,1)='@' then do;
|
||||||
else type='N';
|
if substr(fmtname,2,1)='$' then type='J';
|
||||||
|
else type='I';
|
||||||
|
end;
|
||||||
|
else do;
|
||||||
|
if substr(fmtname,1,1)='$' then type='C';
|
||||||
|
else type='N';
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
if type='N' then do;
|
if type in ('N','I') then do;
|
||||||
start=cats(start);
|
%mp_aligndecimal(start,width=16)
|
||||||
end=cats(end);
|
%mp_aligndecimal(end,width=16)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
/* update row marker - retain new var as fmtrow may already be in libds */
|
||||||
|
if first.fmtname then row=1;
|
||||||
|
else row+1;
|
||||||
|
drop row;
|
||||||
|
fmtrow=row;
|
||||||
|
|
||||||
|
fmthash=%mp_md5(cvars=&cvars, nvars=&nvars);
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,11 +194,10 @@ create table &outds_add(drop=&delete_col) as
|
|||||||
select a.*
|
select a.*
|
||||||
from &inlibds a
|
from &inlibds a
|
||||||
left join &base_fmts b
|
left join &base_fmts b
|
||||||
on a.fmtname=b.fmtname
|
on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
|
||||||
and a.start=b.start
|
|
||||||
where b.fmtname is null
|
where b.fmtname is null
|
||||||
and upcase(a.&delete_col) ne "YES"
|
and upcase(a.&delete_col) ne "YES"
|
||||||
order by fmtname, start;;
|
order by type, fmtname, fmtrow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify deleted records
|
* Identify deleted records
|
||||||
@@ -180,10 +206,9 @@ create table &outds_del(drop=&delete_col) as
|
|||||||
select a.*
|
select a.*
|
||||||
from &inlibds a
|
from &inlibds a
|
||||||
inner join &base_fmts b
|
inner join &base_fmts b
|
||||||
on a.fmtname=b.fmtname
|
on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
|
||||||
and a.start=b.start
|
|
||||||
where upcase(a.&delete_col)="YES"
|
where upcase(a.&delete_col)="YES"
|
||||||
order by fmtname, start;
|
order by type, fmtname, fmtrow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify modified records
|
* Identify modified records
|
||||||
@@ -192,12 +217,10 @@ create table &outds_mod (drop=&delete_col) as
|
|||||||
select a.*
|
select a.*
|
||||||
from &inlibds a
|
from &inlibds a
|
||||||
inner join &base_fmts b
|
inner join &base_fmts b
|
||||||
on a.fmtname=b.fmtname
|
on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
|
||||||
and a.start=b.start
|
|
||||||
where upcase(a.&delete_col) ne "YES"
|
where upcase(a.&delete_col) ne "YES"
|
||||||
order by fmtname, start;
|
and a.fmthash ne b.fmthash
|
||||||
|
order by type, fmtname, fmtrow;
|
||||||
options ibufsize=&ibufsize;
|
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
@@ -206,19 +229,21 @@ options ibufsize=&ibufsize;
|
|||||||
)
|
)
|
||||||
|
|
||||||
%if &loadtarget=YES %then %do;
|
%if &loadtarget=YES %then %do;
|
||||||
|
/* new records plus base records that are not deleted or modified */
|
||||||
data &ds1;
|
data &ds1;
|
||||||
merge &base_fmts(in=base)
|
merge &base_fmts(in=base)
|
||||||
&outds_mod(in=mod)
|
&outds_mod(in=mod)
|
||||||
&outds_add(in=add)
|
&outds_add(in=add)
|
||||||
&outds_del(in=del);
|
&outds_del(in=del);
|
||||||
if not del and not mod;
|
if not del and not mod;
|
||||||
by fmtname start;
|
by type fmtname fmtrow;
|
||||||
run;
|
run;
|
||||||
|
/* add back the modified records */
|
||||||
data &stagedata;
|
data &stagedata;
|
||||||
set &ds1 &outds_mod;
|
set &ds1 &outds_mod;
|
||||||
run;
|
run;
|
||||||
proc sort;
|
proc sort;
|
||||||
by fmtname start;
|
by type fmtname fmtrow;
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
/* mp abort needs to run outside of conditional blocks */
|
/* mp abort needs to run outside of conditional blocks */
|
||||||
@@ -266,7 +291,7 @@ options ibufsize=&ibufsize;
|
|||||||
|
|
||||||
%mp_storediffs(&libcat-FC
|
%mp_storediffs(&libcat-FC
|
||||||
,&base_fmts
|
,&base_fmts
|
||||||
,FMTNAME START
|
,TYPE FMTNAME FMTROW
|
||||||
,delds=&outds_del
|
,delds=&outds_del
|
||||||
,modds=&outds_mod
|
,modds=&outds_mod
|
||||||
,appds=&outds_add
|
,appds=&outds_add
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ run;
|
|||||||
data _null_;
|
data _null_;
|
||||||
putlog 'NOTE-' / 'NOTE-';
|
putlog 'NOTE-' / 'NOTE-';
|
||||||
putlog "NOTE- &sysmacroname: table locked, waiting "@;
|
putlog "NOTE- &sysmacroname: table locked, waiting "@;
|
||||||
putlog "%sysfunc(sleep(&loop_inc)) seconds.. ";
|
putlog "%sysfunc(sleep(&loop_secs)) seconds.. ";
|
||||||
putlog "NOTE- (iteration &x of &loops)";
|
putlog "NOTE- (iteration &x of &loops)";
|
||||||
putlog 'NOTE-' / 'NOTE-';
|
putlog 'NOTE-' / 'NOTE-';
|
||||||
run;
|
run;
|
||||||
@@ -200,7 +200,10 @@ run;
|
|||||||
where LOCK_LIB ="&lib" and LOCK_DS="&ds";
|
where LOCK_LIB ="&lib" and LOCK_DS="&ds";
|
||||||
quit;
|
quit;
|
||||||
%if &syscc>0 %then %put syscc=&syscc sqlrc=&sqlrc;
|
%if &syscc>0 %then %put syscc=&syscc sqlrc=&sqlrc;
|
||||||
%if &status=LOCKED %then %do;
|
%if &sqlobs=0 %then %do;
|
||||||
|
%put %str(WAR)NING: &lib..&ds has never been locked!;
|
||||||
|
%end;
|
||||||
|
%else %if &status=LOCKED %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
putlog "&sysmacroname: unlocking &lib..&ds:";
|
putlog "&sysmacroname: unlocking &lib..&ds:";
|
||||||
run;
|
run;
|
||||||
|
|||||||
@@ -147,9 +147,9 @@ run;
|
|||||||
|
|
||||||
%if %index(&libds,-)>0 and %scan(&libds,2,-)=FC %then %do;
|
%if %index(&libds,-)>0 and %scan(&libds,2,-)=FC %then %do;
|
||||||
/* this is a format catalog - cannot query cols directly */
|
/* this is a format catalog - cannot query cols directly */
|
||||||
%let vlist="FMTNAME","START","END","LABEL","MIN","MAX","DEFAULT","LENGTH"
|
%let vlist="TYPE","FMTNAME","FMTROW","START","END","LABEL","MIN","MAX"
|
||||||
,"FUZZ","PREFIX","MULT","FILL","NOEDIT","TYPE","SEXCL","EEXCL","HLO"
|
,"DEFAULT","LENGTH","FUZZ","PREFIX","MULT","FILL","NOEDIT","SEXCL"
|
||||||
,"DECSEP","DIG3SEP","DATATYPE","LANGUAGE";
|
,"EEXCL","HLO","DECSEP","DIG3SEP","DATATYPE","LANGUAGE";
|
||||||
%end;
|
%end;
|
||||||
%else %let vlist=%mf_getvarlist(&libds,dlm=%str(,),quote=DOUBLE);
|
%else %let vlist=%mf_getvarlist(&libds,dlm=%str(,),quote=DOUBLE);
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,27 @@
|
|||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief The CNTLOUT table generated by proc format
|
@brief The CNTLOUT table generated by proc format
|
||||||
@details This table will actually change format depending on the data values,
|
@details The actual CNTLOUT table may have varying variable lengths,
|
||||||
therefore the max possible lengths are described here to enable consistency
|
depending on the data values, therefore the max possible lengths
|
||||||
when dealing with format data.
|
(given various practical restrictions) are described here to enable
|
||||||
|
consistency when dealing with format data.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
%macro mddl_sas_cntlout(libds=WORK.CNTLOUT);
|
%macro mddl_sas_cntlout(libds=WORK.CNTLOUT);
|
||||||
|
|
||||||
proc sql;
|
proc sql;
|
||||||
create table &libds(
|
create table &libds(
|
||||||
FMTNAME char(32) label='Format name'
|
TYPE char(1) label='Type of format - either N (num fmt), C (char fmt), I (num infmt) or J (char infmt)'
|
||||||
|
,FMTNAME char(32) label='Format name'
|
||||||
|
,FMTROW num label='CALCULATED Position of record by FMTNAME (reqd for multilabel formats)'
|
||||||
|
,START char(32767) label='Starting value for format'
|
||||||
/*
|
/*
|
||||||
to accommodate larger START values, mp_loadformat.sas will need the
|
Keep lengths of START and END the same to avoid this err:
|
||||||
SQL dependency removed (proc sql needs to accommodate 3 index values in
|
"Start is greater than end: -<."
|
||||||
a 32767 ibufsize limit)
|
Similar usage note: https://support.sas.com/kb/69/330.html
|
||||||
*/
|
*/
|
||||||
,START char(10000) label='Starting value for format'
|
|
||||||
,END char(32767) label='Ending value for format'
|
,END char(32767) label='Ending value for format'
|
||||||
,LABEL char(32767) label='Format value label'
|
,LABEL char(32767) label='Format value label'
|
||||||
,MIN num length=3 label='Minimum length'
|
,MIN num length=3 label='Minimum length'
|
||||||
@@ -30,14 +33,25 @@ create table &libds(
|
|||||||
,MULT num label='Multiplier'
|
,MULT num label='Multiplier'
|
||||||
,FILL char(1) label='Fill character'
|
,FILL char(1) label='Fill character'
|
||||||
,NOEDIT num length=3 label='Is picture string noedit?'
|
,NOEDIT num length=3 label='Is picture string noedit?'
|
||||||
,TYPE char(1) label='Type of format'
|
|
||||||
,SEXCL char(1) label='Start exclusion'
|
,SEXCL char(1) label='Start exclusion'
|
||||||
,EEXCL char(1) label='End exclusion'
|
,EEXCL char(1) label='End exclusion'
|
||||||
,HLO char(13) label='Additional information'
|
,HLO char(13) label='Additional information. M=MultiLabel'
|
||||||
,DECSEP char(1) label='Decimal separator'
|
,DECSEP char(1) label='Decimal separator'
|
||||||
,DIG3SEP char(1) label='Three-digit separator'
|
,DIG3SEP char(1) label='Three-digit separator'
|
||||||
,DATATYPE char(8) label='Date/time/datetime?'
|
,DATATYPE char(8) label='Date/time/datetime?'
|
||||||
,LANGUAGE char(8) label='Language for date strings'
|
,LANGUAGE char(8) label='Language for date strings'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
%local lib;
|
||||||
|
%let libds=%upcase(&libds);
|
||||||
|
%if %index(&libds,.)=0 %then %let lib=WORK;
|
||||||
|
%else %let lib=%scan(&libds,1,.);
|
||||||
|
|
||||||
|
proc datasets lib=&lib noprint;
|
||||||
|
modify %scan(&libds,-1,.);
|
||||||
|
index create
|
||||||
|
pk_cntlout=(type fmtname fmtrow)
|
||||||
|
/nomiss unique;
|
||||||
|
quit;
|
||||||
|
|
||||||
%mend mddl_sas_cntlout;
|
%mend mddl_sas_cntlout;
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ run;
|
|||||||
filename __us2grp temp;
|
filename __us2grp temp;
|
||||||
|
|
||||||
proc metadata in= "<UpdateMetadata><Reposid>$METAREPOSITORY</Reposid><Metadata>
|
proc metadata in= "<UpdateMetadata><Reposid>$METAREPOSITORY</Reposid><Metadata>
|
||||||
<Person Id='&uuri'><IdentityGroups><IdentityGroup ObjRef='&guri' />
|
<Person Id='%nrstr(&uuri)'>
|
||||||
|
<IdentityGroups><IdentityGroup ObjRef='%nrstr(&guri)' />
|
||||||
</IdentityGroups></Person></Metadata>
|
</IdentityGroups></Person></Metadata>
|
||||||
<NS>SAS</NS><Flags>268435456</Flags></UpdateMetadata>"
|
<NS>SAS</NS><Flags>268435456</Flags></UpdateMetadata>"
|
||||||
out=__us2grp verbose;
|
out=__us2grp verbose;
|
||||||
@@ -98,4 +99,4 @@ run;
|
|||||||
|
|
||||||
filename __us2grp clear;
|
filename __us2grp clear;
|
||||||
|
|
||||||
%mend mm_adduser2group;
|
%mend mm_adduser2group;
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ data _null_;
|
|||||||
put ' put " ""&wt"" : {"; ';
|
put ' put " ""&wt"" : {"; ';
|
||||||
put ' put ''"nlobs":'' nlobs; ';
|
put ' put ''"nlobs":'' nlobs; ';
|
||||||
put ' put '',"nvars":'' nvars; ';
|
put ' put '',"nvars":'' nvars; ';
|
||||||
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10 ';
|
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y ';
|
||||||
put ' ,maxobs=&workobs ';
|
put ' ,maxobs=&workobs ';
|
||||||
put ' ) ';
|
put ' ) ';
|
||||||
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
||||||
@@ -571,7 +571,25 @@ data _null_;
|
|||||||
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
||||||
put ' syserrortext=cats(''"'',tranwrd(symget(''syserrortext''),''"'',''\"''),''"''); ';
|
put ' syserrortext=cats(symget(''syserrortext'')); ';
|
||||||
|
put ' if findc(syserrortext,''"\''!!''0A0D09000E0F010210111A''x) then do; ';
|
||||||
|
put ' syserrortext=''"''!!trim( ';
|
||||||
|
put ' prxchange(''s/"/\\"/'',-1, /* double quote */ ';
|
||||||
|
put ' prxchange(''s/\x0A/\n/'',-1, /* new line */ ';
|
||||||
|
put ' prxchange(''s/\x0D/\r/'',-1, /* carriage return */ ';
|
||||||
|
put ' prxchange(''s/\x09/\\t/'',-1, /* tab */ ';
|
||||||
|
put ' prxchange(''s/\x00/\\u0000/'',-1, /* NUL */ ';
|
||||||
|
put ' prxchange(''s/\x0E/\\u000E/'',-1, /* SS */ ';
|
||||||
|
put ' prxchange(''s/\x0F/\\u000F/'',-1, /* SF */ ';
|
||||||
|
put ' prxchange(''s/\x01/\\u0001/'',-1, /* SOH */ ';
|
||||||
|
put ' prxchange(''s/\x02/\\u0002/'',-1, /* STX */ ';
|
||||||
|
put ' prxchange(''s/\x10/\\u0010/'',-1, /* DLE */ ';
|
||||||
|
put ' prxchange(''s/\x11/\\u0011/'',-1, /* DC1 */ ';
|
||||||
|
put ' prxchange(''s/\x1A/\\u001A/'',-1, /* SUB */ ';
|
||||||
|
put ' prxchange(''s/\\/\\\\/'',-1,syserrortext) ';
|
||||||
|
put ' )))))))))))))!!''"''; ';
|
||||||
|
put ' end; ';
|
||||||
|
put ' else syserrortext=cats(''"'',syserrortext,''"''); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
||||||
put ' put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" "; ';
|
put ' put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" "; ';
|
||||||
@@ -584,7 +602,25 @@ data _null_;
|
|||||||
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
||||||
put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
|
put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
|
||||||
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
||||||
put ' syswarningtext=cats(''"'',tranwrd(symget(''syswarningtext''),''"'',''\"''),''"''); ';
|
put ' syswarningtext=cats(symget(''syswarningtext'')); ';
|
||||||
|
put ' if findc(syswarningtext,''"\''!!''0A0D09000E0F010210111A''x) then do; ';
|
||||||
|
put ' syswarningtext=''"''!!trim( ';
|
||||||
|
put ' prxchange(''s/"/\\"/'',-1, /* double quote */ ';
|
||||||
|
put ' prxchange(''s/\x0A/\n/'',-1, /* new line */ ';
|
||||||
|
put ' prxchange(''s/\x0D/\r/'',-1, /* carriage return */ ';
|
||||||
|
put ' prxchange(''s/\x09/\\t/'',-1, /* tab */ ';
|
||||||
|
put ' prxchange(''s/\x00/\\u0000/'',-1, /* NUL */ ';
|
||||||
|
put ' prxchange(''s/\x0E/\\u000E/'',-1, /* SS */ ';
|
||||||
|
put ' prxchange(''s/\x0F/\\u000F/'',-1, /* SF */ ';
|
||||||
|
put ' prxchange(''s/\x01/\\u0001/'',-1, /* SOH */ ';
|
||||||
|
put ' prxchange(''s/\x02/\\u0002/'',-1, /* STX */ ';
|
||||||
|
put ' prxchange(''s/\x10/\\u0010/'',-1, /* DLE */ ';
|
||||||
|
put ' prxchange(''s/\x11/\\u0011/'',-1, /* DC1 */ ';
|
||||||
|
put ' prxchange(''s/\x1A/\\u001A/'',-1, /* SUB */ ';
|
||||||
|
put ' prxchange(''s/\\/\\\\/'',-1,syswarningtext) ';
|
||||||
|
put ' )))))))))))))!!''"''; ';
|
||||||
|
put ' end; ';
|
||||||
|
put ' else syswarningtext=cats(''"'',syswarningtext,''"''); ';
|
||||||
put ' put '',"SYSWARNINGTEXT" : '' syswarningtext; ';
|
put ' put '',"SYSWARNINGTEXT" : '' syswarningtext; ';
|
||||||
put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''" ''; ';
|
put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''" ''; ';
|
||||||
put ' length memsize $32; ';
|
put ' length memsize $32; ';
|
||||||
@@ -610,9 +646,11 @@ data _null_;
|
|||||||
put ' ';
|
put ' ';
|
||||||
put '%mend mm_webout; ';
|
put '%mend mm_webout; ';
|
||||||
/* WEBOUT END */
|
/* WEBOUT END */
|
||||||
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);';
|
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO';
|
||||||
|
put ' ,maxobs=MAX';
|
||||||
|
put ');';
|
||||||
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
||||||
put ' ,showmeta=&showmeta';
|
put ' ,showmeta=&showmeta,maxobs=&maxobs';
|
||||||
put ' )';
|
put ' )';
|
||||||
put '%mend;';
|
put '%mend;';
|
||||||
run;
|
run;
|
||||||
|
|||||||
@@ -150,7 +150,7 @@
|
|||||||
put " ""&wt"" : {";
|
put " ""&wt"" : {";
|
||||||
put '"nlobs":' nlobs;
|
put '"nlobs":' nlobs;
|
||||||
put ',"nvars":' nvars;
|
put ',"nvars":' nvars;
|
||||||
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10
|
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y
|
||||||
,maxobs=&workobs
|
,maxobs=&workobs
|
||||||
)
|
)
|
||||||
data _null_; file _sjsref mod encoding='utf-8';
|
data _null_; file _sjsref mod encoding='utf-8';
|
||||||
@@ -175,7 +175,25 @@
|
|||||||
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
||||||
syserrortext=cats('"',tranwrd(symget('syserrortext'),'"','\"'),'"');
|
syserrortext=cats(symget('syserrortext'));
|
||||||
|
if findc(syserrortext,'"\'!!'0A0D09000E0F010210111A'x) then do;
|
||||||
|
syserrortext='"'!!trim(
|
||||||
|
prxchange('s/"/\\"/',-1, /* double quote */
|
||||||
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
||||||
|
prxchange('s/\x0D/\r/',-1, /* carriage return */
|
||||||
|
prxchange('s/\x09/\\t/',-1, /* tab */
|
||||||
|
prxchange('s/\x00/\\u0000/',-1, /* NUL */
|
||||||
|
prxchange('s/\x0E/\\u000E/',-1, /* SS */
|
||||||
|
prxchange('s/\x0F/\\u000F/',-1, /* SF */
|
||||||
|
prxchange('s/\x01/\\u0001/',-1, /* SOH */
|
||||||
|
prxchange('s/\x02/\\u0002/',-1, /* STX */
|
||||||
|
prxchange('s/\x10/\\u0010/',-1, /* DLE */
|
||||||
|
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
|
||||||
|
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
|
||||||
|
prxchange('s/\\/\\\\/',-1,syserrortext)
|
||||||
|
)))))))))))))!!'"';
|
||||||
|
end;
|
||||||
|
else syserrortext=cats('"',syserrortext,'"');
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
||||||
put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" ";
|
put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" ";
|
||||||
@@ -188,7 +206,25 @@
|
|||||||
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
||||||
sysvlong=quote(trim(symget('sysvlong')));
|
sysvlong=quote(trim(symget('sysvlong')));
|
||||||
put ',"SYSVLONG" : ' sysvlong;
|
put ',"SYSVLONG" : ' sysvlong;
|
||||||
syswarningtext=cats('"',tranwrd(symget('syswarningtext'),'"','\"'),'"');
|
syswarningtext=cats(symget('syswarningtext'));
|
||||||
|
if findc(syswarningtext,'"\'!!'0A0D09000E0F010210111A'x) then do;
|
||||||
|
syswarningtext='"'!!trim(
|
||||||
|
prxchange('s/"/\\"/',-1, /* double quote */
|
||||||
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
||||||
|
prxchange('s/\x0D/\r/',-1, /* carriage return */
|
||||||
|
prxchange('s/\x09/\\t/',-1, /* tab */
|
||||||
|
prxchange('s/\x00/\\u0000/',-1, /* NUL */
|
||||||
|
prxchange('s/\x0E/\\u000E/',-1, /* SS */
|
||||||
|
prxchange('s/\x0F/\\u000F/',-1, /* SF */
|
||||||
|
prxchange('s/\x01/\\u0001/',-1, /* SOH */
|
||||||
|
prxchange('s/\x02/\\u0002/',-1, /* STX */
|
||||||
|
prxchange('s/\x10/\\u0010/',-1, /* DLE */
|
||||||
|
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
|
||||||
|
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
|
||||||
|
prxchange('s/\\/\\\\/',-1,syswarningtext)
|
||||||
|
)))))))))))))!!'"';
|
||||||
|
end;
|
||||||
|
else syswarningtext=cats('"',syswarningtext,'"');
|
||||||
put ',"SYSWARNINGTEXT" : ' syswarningtext;
|
put ',"SYSWARNINGTEXT" : ' syswarningtext;
|
||||||
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
||||||
length memsize $32;
|
length memsize $32;
|
||||||
|
|||||||
989
package-lock.json
generated
989
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -33,6 +33,6 @@
|
|||||||
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
|
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sasjs/cli": "3.13.0"
|
"@sasjs/cli": "3.24.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,12 +67,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"serverUrl": "https://sas.4gl.io",
|
"serverUrl": "https://sas9.4gl.io",
|
||||||
"serverType": "SASJS",
|
"serverType": "SASJS",
|
||||||
"httpsAgentOptions": {
|
"httpsAgentOptions": {
|
||||||
"allowInsecureRequests": false
|
"allowInsecureRequests": false
|
||||||
},
|
},
|
||||||
"appLoc": "/sasjs/core",
|
"appLoc": "/sasjs/core",
|
||||||
|
"deployConfig": {
|
||||||
|
"deployServicePack": true,
|
||||||
|
"deployScripts": []
|
||||||
|
},
|
||||||
"macroFolders": [
|
"macroFolders": [
|
||||||
"server",
|
"server",
|
||||||
"tests/serveronly"
|
"tests/serveronly"
|
||||||
@@ -81,7 +85,7 @@
|
|||||||
{
|
{
|
||||||
"name": "docsonly",
|
"name": "docsonly",
|
||||||
"serverType": "SASJS",
|
"serverType": "SASJS",
|
||||||
"appLoc": "dummy",
|
"appLoc": "/dummy",
|
||||||
"macroFolders": [
|
"macroFolders": [
|
||||||
"meta",
|
"meta",
|
||||||
"metax",
|
"metax",
|
||||||
@@ -105,6 +109,16 @@
|
|||||||
"deployServicePack": true
|
"deployServicePack": true
|
||||||
},
|
},
|
||||||
"contextName": "SAS Job Execution compute context"
|
"contextName": "SAS Job Execution compute context"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sasjs9",
|
||||||
|
"serverUrl": "https://sas9.4gl.io",
|
||||||
|
"serverType": "SASJS",
|
||||||
|
"appLoc": "/Public/app/sasjs9",
|
||||||
|
"deployConfig": {
|
||||||
|
"deployServicePack": true,
|
||||||
|
"deployScripts": []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
224
sasjs/utils/create_sas_package.sas
Normal file
224
sasjs/utils/create_sas_package.sas
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Deploy repo as a SAS PACKAGES module
|
||||||
|
@details After every release, this program is executed to update the SASPAC
|
||||||
|
repo with the latest macros (and same version number).
|
||||||
|
The program is first compiled using sasjs compile, then executed using
|
||||||
|
sasjs run.
|
||||||
|
|
||||||
|
Requires the server to have SSH keys.
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_gitadd.sas
|
||||||
|
@li mp_gitreleaseinfo.sas
|
||||||
|
@li mp_gitstatus.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
/* get package version */
|
||||||
|
%mp_gitreleaseinfo(GITHUB,sasjs/core,outlib=splib)
|
||||||
|
data _null_;
|
||||||
|
set splib.root;
|
||||||
|
call symputx('version',substr(TAG_NAME,2));
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* clone the source repo */
|
||||||
|
%let dir = %sysfunc(pathname(work))/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(https://github.com/sasjs/core,&dir));
|
||||||
|
|
||||||
|
/*
|
||||||
|
clone the target repo.
|
||||||
|
If you have issues, see: https://stackoverflow.com/questions/74082874
|
||||||
|
*/
|
||||||
|
options dlcreatedir;
|
||||||
|
%let dirOut = %sysfunc(pathname(work))/package;
|
||||||
|
libname _ "&dirOut.";
|
||||||
|
|
||||||
|
%put tgt clone rc=%sysfunc(GITFN_CLONE(
|
||||||
|
git@github.com:SASPAC/sasjscore.git,
|
||||||
|
&dirOut,
|
||||||
|
git,
|
||||||
|
%str( ),
|
||||||
|
/home/sasjssrv/.ssh/id_ecdsa.pub,
|
||||||
|
/home/sasjssrv/.ssh/id_ecdsa
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Prepare Package Metadata
|
||||||
|
*/
|
||||||
|
data _null_;
|
||||||
|
infile CARDS4;
|
||||||
|
file "&dirOut./description.sas";
|
||||||
|
input;
|
||||||
|
if _infile_ =: 'Version:' then put "Version: &version.";
|
||||||
|
else put _infile_;
|
||||||
|
CARDS4;
|
||||||
|
Type: Package
|
||||||
|
Package: SASjsCore
|
||||||
|
Title: SAS Macros for Application Development
|
||||||
|
Version: $(PLACEHOLDER)
|
||||||
|
Author: Allan Bowe
|
||||||
|
Maintainer: 4GL Ltd
|
||||||
|
License: MIT
|
||||||
|
Encoding: UTF8
|
||||||
|
|
||||||
|
DESCRIPTION START:
|
||||||
|
|
||||||
|
The SASjs Macro Core library is a component of the SASjs framework, the
|
||||||
|
source for which is avaible here: https://github.com/sasjs
|
||||||
|
|
||||||
|
Macros are divided by:
|
||||||
|
|
||||||
|
* Macro Functions (prefix mf_)
|
||||||
|
* Macro Procedures (prefix mp_)
|
||||||
|
* Macros for Metadata (prefix mm_)
|
||||||
|
* Macros for SASjs Server (prefix ms_)
|
||||||
|
* Macros for Viya (prefix mv_)
|
||||||
|
|
||||||
|
DESCRIPTION END:
|
||||||
|
;;;;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Prepare Package License
|
||||||
|
*/
|
||||||
|
data _null_;
|
||||||
|
file "&dirOut./license.sas";
|
||||||
|
infile "&dir/LICENSE";
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Extract Core files into MacroCore Package location
|
||||||
|
*/
|
||||||
|
data members(compress=char);
|
||||||
|
length dref dref2 $ 8 name name2 $ 32 path $ 2048;
|
||||||
|
rc = filename(dref, "&dir.");
|
||||||
|
put dref=;
|
||||||
|
did = dopen(dref);
|
||||||
|
if did then
|
||||||
|
do i = 1 to dnum(did);
|
||||||
|
name = dread(did, i);
|
||||||
|
if name in
|
||||||
|
("base" "ddl" "fcmp" "lua" "meta" "metax" "server" "viya" "xplatform")
|
||||||
|
then do;
|
||||||
|
rc = filename(dref2,catx("/", "&dir.", name));
|
||||||
|
put dref2= name;
|
||||||
|
did2 = dopen(dref2);
|
||||||
|
|
||||||
|
if did2 then
|
||||||
|
do j = 1 to dnum(did2);
|
||||||
|
name2 = dread(did2, j);
|
||||||
|
path = catx("/", "&dir.", name, name2);
|
||||||
|
if "sas" = scan(name2, -1, ".") then output;
|
||||||
|
end;
|
||||||
|
rc = dclose(did2);
|
||||||
|
rc = filename(dref2);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
rc = dclose(did);
|
||||||
|
rc = filename(dref);
|
||||||
|
keep name name2 path;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%let temp_options = %sysfunc(getoption(source)) %sysfunc(getoption(notes));
|
||||||
|
options nosource nonotes;
|
||||||
|
data _null_;
|
||||||
|
set members;
|
||||||
|
by name notsorted;
|
||||||
|
|
||||||
|
ord + first.name;
|
||||||
|
|
||||||
|
if first.name then
|
||||||
|
do;
|
||||||
|
call execute('libname _ '
|
||||||
|
!! quote(catx("/", "&dirOut.", put(ord, z3.)!!"_macros"))
|
||||||
|
!! ";"
|
||||||
|
);
|
||||||
|
put @1 "./" ord z3. "_macros/";
|
||||||
|
end;
|
||||||
|
|
||||||
|
put @10 name2;
|
||||||
|
call execute("
|
||||||
|
data _null_;
|
||||||
|
infile " !! quote(strip(path)) !! ";
|
||||||
|
file " !! quote(catx("/", "&dirOut.", put(ord, z3.)!!"_macros", name2)) !!";
|
||||||
|
input;
|
||||||
|
select;
|
||||||
|
when (2 = trigger) put _infile_;
|
||||||
|
when (_infile_ = '/**') do; put '/*** HELP START ***//**'; trigger+1; end;
|
||||||
|
when (_infile_ = '**/') do; put '**//*** HELP END ***/'; trigger+1; end;
|
||||||
|
otherwise put _infile_;
|
||||||
|
end;
|
||||||
|
run;");
|
||||||
|
|
||||||
|
run;
|
||||||
|
options &temp_options.;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generate SASjsCore Package
|
||||||
|
*/
|
||||||
|
%GeneratePackage(
|
||||||
|
filesLocation=&dirOut
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* apply new version in a github action
|
||||||
|
* 1. create folder
|
||||||
|
* 2. create template yaml
|
||||||
|
* 3. replace version number
|
||||||
|
*/
|
||||||
|
|
||||||
|
%mf_mkdir(&dirout/.github/workflows)
|
||||||
|
|
||||||
|
%let desc=Version &version of sasjs/core is now on SAS PACKAGES :ok_hand:;
|
||||||
|
data _null_;
|
||||||
|
file "&dirout/.github/workflows/release.yml";
|
||||||
|
put "name: SASjs Core Package Publish Tag";
|
||||||
|
put "on:";
|
||||||
|
put " push:";
|
||||||
|
put " branches:";
|
||||||
|
put " - main";
|
||||||
|
put "jobs:";
|
||||||
|
put " update:";
|
||||||
|
put " runs-on: ubuntu-latest";
|
||||||
|
put " steps:";
|
||||||
|
put " - uses: actions/checkout@master";
|
||||||
|
put " - name: Make Release";
|
||||||
|
put " uses: alice-biometrics/release-creator/@v1.0.5";
|
||||||
|
put " with:";
|
||||||
|
put " github_token: ${{ secrets.GH_TOKEN }}";
|
||||||
|
put " branch: main";
|
||||||
|
put " draft: false";
|
||||||
|
put " version: &version";
|
||||||
|
put " description: '&desc'";
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add, Commit & Push!
|
||||||
|
*/
|
||||||
|
%mp_gitstatus(&dirout,outds=work.gitstatus,mdebug=1)
|
||||||
|
%mp_gitadd(&dirout,inds=work.gitstatus,mdebug=1)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
rc=gitfn_commit("&dirout"
|
||||||
|
,"HEAD","&sysuserid","sasjs@core"
|
||||||
|
,"FEAT: Releasing &version"
|
||||||
|
);
|
||||||
|
put rc=;
|
||||||
|
rc=git_push(
|
||||||
|
"&dirout"
|
||||||
|
,"git"
|
||||||
|
,""
|
||||||
|
,"/home/sasjssrv/.ssh/id_ecdsa.pub"
|
||||||
|
,"/home/sasjssrv/.ssh/id_ecdsa"
|
||||||
|
);
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -539,7 +539,7 @@ data _null_;
|
|||||||
put ' put " ""&wt"" : {"; ';
|
put ' put " ""&wt"" : {"; ';
|
||||||
put ' put ''"nlobs":'' nlobs; ';
|
put ' put ''"nlobs":'' nlobs; ';
|
||||||
put ' put '',"nvars":'' nvars; ';
|
put ' put '',"nvars":'' nvars; ';
|
||||||
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10 ';
|
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y ';
|
||||||
put ' ,maxobs=&workobs ';
|
put ' ,maxobs=&workobs ';
|
||||||
put ' ) ';
|
put ' ) ';
|
||||||
put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; ';
|
put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; ';
|
||||||
@@ -560,7 +560,25 @@ data _null_;
|
|||||||
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
||||||
put ' syserrortext=cats(''"'',tranwrd(symget(''syserrortext''),''"'',''\"''),''"''); ';
|
put ' syserrortext=cats(symget(''syserrortext'')); ';
|
||||||
|
put ' if findc(syserrortext,''"\''!!''0A0D09000E0F010210111A''x) then do; ';
|
||||||
|
put ' syserrortext=''"''!!trim( ';
|
||||||
|
put ' prxchange(''s/"/\\"/'',-1, /* double quote */ ';
|
||||||
|
put ' prxchange(''s/\x0A/\n/'',-1, /* new line */ ';
|
||||||
|
put ' prxchange(''s/\x0D/\r/'',-1, /* carriage return */ ';
|
||||||
|
put ' prxchange(''s/\x09/\\t/'',-1, /* tab */ ';
|
||||||
|
put ' prxchange(''s/\x00/\\u0000/'',-1, /* NUL */ ';
|
||||||
|
put ' prxchange(''s/\x0E/\\u000E/'',-1, /* SS */ ';
|
||||||
|
put ' prxchange(''s/\x0F/\\u000F/'',-1, /* SF */ ';
|
||||||
|
put ' prxchange(''s/\x01/\\u0001/'',-1, /* SOH */ ';
|
||||||
|
put ' prxchange(''s/\x02/\\u0002/'',-1, /* STX */ ';
|
||||||
|
put ' prxchange(''s/\x10/\\u0010/'',-1, /* DLE */ ';
|
||||||
|
put ' prxchange(''s/\x11/\\u0011/'',-1, /* DC1 */ ';
|
||||||
|
put ' prxchange(''s/\x1A/\\u001A/'',-1, /* SUB */ ';
|
||||||
|
put ' prxchange(''s/\\/\\\\/'',-1,syserrortext) ';
|
||||||
|
put ' )))))))))))))!!''"''; ';
|
||||||
|
put ' end; ';
|
||||||
|
put ' else syserrortext=cats(''"'',syserrortext,''"''); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' SYSHOSTINFOLONG=quote(trim(symget(''SYSHOSTINFOLONG''))); ';
|
put ' SYSHOSTINFOLONG=quote(trim(symget(''SYSHOSTINFOLONG''))); ';
|
||||||
put ' put '',"SYSHOSTINFOLONG" : '' SYSHOSTINFOLONG; ';
|
put ' put '',"SYSHOSTINFOLONG" : '' SYSHOSTINFOLONG; ';
|
||||||
@@ -576,7 +594,25 @@ data _null_;
|
|||||||
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
||||||
put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
|
put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
|
||||||
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
||||||
put ' syswarningtext=cats(''"'',tranwrd(symget(''syswarningtext''),''"'',''\"''),''"''); ';
|
put ' syswarningtext=cats(symget(''syswarningtext'')); ';
|
||||||
|
put ' if findc(syswarningtext,''"\''!!''0A0D09000E0F010210111A''x) then do; ';
|
||||||
|
put ' syswarningtext=''"''!!trim( ';
|
||||||
|
put ' prxchange(''s/"/\\"/'',-1, /* double quote */ ';
|
||||||
|
put ' prxchange(''s/\x0A/\n/'',-1, /* new line */ ';
|
||||||
|
put ' prxchange(''s/\x0D/\r/'',-1, /* carriage return */ ';
|
||||||
|
put ' prxchange(''s/\x09/\\t/'',-1, /* tab */ ';
|
||||||
|
put ' prxchange(''s/\x00/\\u0000/'',-1, /* NUL */ ';
|
||||||
|
put ' prxchange(''s/\x0E/\\u000E/'',-1, /* SS */ ';
|
||||||
|
put ' prxchange(''s/\x0F/\\u000F/'',-1, /* SF */ ';
|
||||||
|
put ' prxchange(''s/\x01/\\u0001/'',-1, /* SOH */ ';
|
||||||
|
put ' prxchange(''s/\x02/\\u0002/'',-1, /* STX */ ';
|
||||||
|
put ' prxchange(''s/\x10/\\u0010/'',-1, /* DLE */ ';
|
||||||
|
put ' prxchange(''s/\x11/\\u0011/'',-1, /* DC1 */ ';
|
||||||
|
put ' prxchange(''s/\x1A/\\u001A/'',-1, /* SUB */ ';
|
||||||
|
put ' prxchange(''s/\\/\\\\/'',-1,syswarningtext) ';
|
||||||
|
put ' )))))))))))))!!''"''; ';
|
||||||
|
put ' end; ';
|
||||||
|
put ' else syswarningtext=cats(''"'',syswarningtext,''"''); ';
|
||||||
put ' put '',"SYSWARNINGTEXT" : '' syswarningtext; ';
|
put ' put '',"SYSWARNINGTEXT" : '' syswarningtext; ';
|
||||||
put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''" ''; ';
|
put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''" ''; ';
|
||||||
put ' length memsize $32; ';
|
put ' length memsize $32; ';
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
@param [in] uid= (0) Provide the userid on which to filter
|
@param [in] uid= (0) Provide the userid on which to filter
|
||||||
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
||||||
list of groups. Format:
|
list of groups. Format:
|
||||||
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
|NAME:$32.|DESCRIPTION:$256.|GROUPID:best.|
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|`SomeGroup `|`A group `|`1`|
|
|`SomeGroup `|`A group `|`1`|
|
||||||
|`Another Group`|`this is a different group`|`2`|
|
|`Another Group`|`this is a different group`|`2`|
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
%if %sysget(MODE)=desktop %then %do;
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
/* groups api does not exist in desktop mode */
|
/* groups api does not exist in desktop mode */
|
||||||
data &outds;
|
data &outds;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
length NAME $32 DESCRIPTION $256. GROUPID 8;
|
||||||
name="&sysuserid";
|
name="&sysuserid";
|
||||||
description="&sysuserid (group - desktop mode)";
|
description="&sysuserid (group - desktop mode)";
|
||||||
groupid=1;
|
groupid=1;
|
||||||
@@ -114,7 +114,7 @@ libname &libref JSON fileref=&fref1;
|
|||||||
|
|
||||||
%if "&user"="0" and "&uid"="0" %then %do;
|
%if "&user"="0" and "&uid"="0" %then %do;
|
||||||
data &outds;
|
data &outds;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
length NAME $32 DESCRIPTION $256. GROUPID 8;
|
||||||
if _n_=1 then call missing(of _all_);
|
if _n_=1 then call missing(of _all_);
|
||||||
set &libref..root;
|
set &libref..root;
|
||||||
drop ordinal_root;
|
drop ordinal_root;
|
||||||
@@ -122,7 +122,7 @@ libname &libref JSON fileref=&fref1;
|
|||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
data &outds;
|
data &outds;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
length NAME $32 DESCRIPTION $256. GROUPID 8;
|
||||||
if _n_=1 then call missing(of _all_);
|
if _n_=1 then call missing(of _all_);
|
||||||
set &libref..groups;
|
set &libref..groups;
|
||||||
drop ordinal_:;
|
drop ordinal_:;
|
||||||
|
|||||||
@@ -39,8 +39,9 @@
|
|||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_getuniquelibref.sas
|
@li mf_getuniquename.sas
|
||||||
@li mp_abort.sas
|
@li mp_abort.sas
|
||||||
|
@li mp_chop.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -153,7 +154,10 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
filename &outref temp lrecl=32767;
|
%local resp_path;
|
||||||
|
%let resp_path=%sysfunc(pathname(work))/%mf_getuniquename();
|
||||||
|
filename &outref "&resp_path" lrecl=32767;
|
||||||
|
|
||||||
/* prepare request*/
|
/* prepare request*/
|
||||||
proc http method='POST' headerin=&authref in=&mainref out=&outref
|
proc http method='POST' headerin=&authref in=&mainref out=&outref
|
||||||
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
|
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
|
||||||
@@ -161,6 +165,7 @@ proc http method='POST' headerin=&authref in=&mainref out=&outref
|
|||||||
debug level=2;
|
debug level=2;
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||||
or &mdebug=1
|
or &mdebug=1
|
||||||
%then %do;
|
%then %do;
|
||||||
@@ -176,11 +181,22 @@ or &mdebug=1
|
|||||||
options &optval;
|
options &optval;
|
||||||
|
|
||||||
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
||||||
%local dumplib;
|
%local matchstr chopout;
|
||||||
%let dumplib=%mf_getuniquelibref();
|
%let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
|
||||||
libname &dumplib json fileref=&outref;
|
%let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
|
||||||
|
|
||||||
|
%mp_chop("&resp_path"
|
||||||
|
,matchvar=matchstr
|
||||||
|
,keep=LAST
|
||||||
|
,matchpoint=END
|
||||||
|
,outfile="&chopout"
|
||||||
|
,mdebug=&mdebug
|
||||||
|
)
|
||||||
|
|
||||||
data &outlogds;
|
data &outlogds;
|
||||||
set &dumplib..log;
|
infile "&chopout" lrecl=2000;
|
||||||
|
length line $2000;
|
||||||
|
line=_infile_;
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
putlog line=;
|
putlog line=;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -108,47 +108,34 @@ run;
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
/* SASjs services have the _webout embedded in wrapper JSON */
|
/* chop out JSON section */
|
||||||
/* Files can also be very large - so use a dedicated macro to chop it out */
|
%local matchstr chopout;
|
||||||
%local matchstr1 matchstr2 ;
|
%let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
|
||||||
%let matchstr1={"status":"success","_webout":{;
|
%let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
|
||||||
%let matchstr2=},"log":[{;
|
|
||||||
%let chopout1=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop1);
|
|
||||||
%let chopout2=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop2);
|
|
||||||
|
|
||||||
%mp_chop("%sysfunc(pathname(&fref1,F))"
|
%mp_chop("%sysfunc(pathname(&fref1,F))"
|
||||||
,matchvar=matchstr1
|
,matchvar=matchstr
|
||||||
,keep=LAST
|
|
||||||
,matchpoint=END
|
|
||||||
,offset=-1
|
|
||||||
,outfile="&chopout1"
|
|
||||||
,mdebug=&mdebug
|
|
||||||
)
|
|
||||||
|
|
||||||
%mp_chop("&chopout1"
|
|
||||||
,matchvar=matchstr2
|
|
||||||
,keep=FIRST
|
,keep=FIRST
|
||||||
,matchpoint=START
|
,matchpoint=START
|
||||||
,offset=1
|
,offset=-1
|
||||||
,outfile="&chopout2"
|
,outfile="&chopout"
|
||||||
,mdebug=&mdebug
|
,mdebug=&mdebug
|
||||||
)
|
)
|
||||||
|
|
||||||
%if &outlib ne 0 %then %do;
|
%if &outlib ne 0 %then %do;
|
||||||
libname &outlib json "&chopout2";
|
libname &outlib json "&chopout";
|
||||||
%end;
|
%end;
|
||||||
%if &outref ne 0 %then %do;
|
%if &outref ne 0 %then %do;
|
||||||
filename &outref "&chopout2";
|
filename &outref "&chopout";
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%if &mdebug=0 %then %do;
|
%if &mdebug=0 %then %do;
|
||||||
filename &webref clear;
|
filename &webref clear;
|
||||||
filename &fref1 clear;
|
filename &fref1 clear;
|
||||||
filename &fref2 clear;
|
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
%put &sysmacroname exit vars:;
|
%put &sysmacroname exit vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend ms_testservice;
|
%mend ms_testservice;
|
||||||
|
|||||||
@@ -141,7 +141,7 @@
|
|||||||
put " ""&wt"" : {";
|
put " ""&wt"" : {";
|
||||||
put '"nlobs":' nlobs;
|
put '"nlobs":' nlobs;
|
||||||
put ',"nvars":' nvars;
|
put ',"nvars":' nvars;
|
||||||
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10
|
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y
|
||||||
,maxobs=&workobs
|
,maxobs=&workobs
|
||||||
)
|
)
|
||||||
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
||||||
@@ -162,7 +162,25 @@
|
|||||||
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
||||||
syserrortext=cats('"',tranwrd(symget('syserrortext'),'"','\"'),'"');
|
syserrortext=cats(symget('syserrortext'));
|
||||||
|
if findc(syserrortext,'"\'!!'0A0D09000E0F010210111A'x) then do;
|
||||||
|
syserrortext='"'!!trim(
|
||||||
|
prxchange('s/"/\\"/',-1, /* double quote */
|
||||||
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
||||||
|
prxchange('s/\x0D/\r/',-1, /* carriage return */
|
||||||
|
prxchange('s/\x09/\\t/',-1, /* tab */
|
||||||
|
prxchange('s/\x00/\\u0000/',-1, /* NUL */
|
||||||
|
prxchange('s/\x0E/\\u000E/',-1, /* SS */
|
||||||
|
prxchange('s/\x0F/\\u000F/',-1, /* SF */
|
||||||
|
prxchange('s/\x01/\\u0001/',-1, /* SOH */
|
||||||
|
prxchange('s/\x02/\\u0002/',-1, /* STX */
|
||||||
|
prxchange('s/\x10/\\u0010/',-1, /* DLE */
|
||||||
|
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
|
||||||
|
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
|
||||||
|
prxchange('s/\\/\\\\/',-1,syserrortext)
|
||||||
|
)))))))))))))!!'"';
|
||||||
|
end;
|
||||||
|
else syserrortext=cats('"',syserrortext,'"');
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
|
SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
|
||||||
put ',"SYSHOSTINFOLONG" : ' SYSHOSTINFOLONG;
|
put ',"SYSHOSTINFOLONG" : ' SYSHOSTINFOLONG;
|
||||||
@@ -178,7 +196,25 @@
|
|||||||
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
||||||
sysvlong=quote(trim(symget('sysvlong')));
|
sysvlong=quote(trim(symget('sysvlong')));
|
||||||
put ',"SYSVLONG" : ' sysvlong;
|
put ',"SYSVLONG" : ' sysvlong;
|
||||||
syswarningtext=cats('"',tranwrd(symget('syswarningtext'),'"','\"'),'"');
|
syswarningtext=cats(symget('syswarningtext'));
|
||||||
|
if findc(syswarningtext,'"\'!!'0A0D09000E0F010210111A'x) then do;
|
||||||
|
syswarningtext='"'!!trim(
|
||||||
|
prxchange('s/"/\\"/',-1, /* double quote */
|
||||||
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
||||||
|
prxchange('s/\x0D/\r/',-1, /* carriage return */
|
||||||
|
prxchange('s/\x09/\\t/',-1, /* tab */
|
||||||
|
prxchange('s/\x00/\\u0000/',-1, /* NUL */
|
||||||
|
prxchange('s/\x0E/\\u000E/',-1, /* SS */
|
||||||
|
prxchange('s/\x0F/\\u000F/',-1, /* SF */
|
||||||
|
prxchange('s/\x01/\\u0001/',-1, /* SOH */
|
||||||
|
prxchange('s/\x02/\\u0002/',-1, /* STX */
|
||||||
|
prxchange('s/\x10/\\u0010/',-1, /* DLE */
|
||||||
|
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
|
||||||
|
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
|
||||||
|
prxchange('s/\\/\\\\/',-1,syswarningtext)
|
||||||
|
)))))))))))))!!'"';
|
||||||
|
end;
|
||||||
|
else syswarningtext=cats('"',syswarningtext,'"');
|
||||||
put ',"SYSWARNINGTEXT" : ' syswarningtext;
|
put ',"SYSWARNINGTEXT" : ' syswarningtext;
|
||||||
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
||||||
length memsize $32;
|
length memsize $32;
|
||||||
|
|||||||
@@ -17,4 +17,24 @@
|
|||||||
%mp_assert(
|
%mp_assert(
|
||||||
iftrue=(%mf_existvar(sashelp.class,isjustanumber)=0),
|
iftrue=(%mf_existvar(sashelp.class,isjustanumber)=0),
|
||||||
desc=Checking non existing var does not exist
|
desc=Checking non existing var does not exist
|
||||||
|
)
|
||||||
|
|
||||||
|
data work.lockcheck;
|
||||||
|
a=1;
|
||||||
|
output;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_existvar(work.lockcheck,)=0),
|
||||||
|
desc=Checking non-provided var does not exist
|
||||||
|
)
|
||||||
|
|
||||||
|
proc sql;
|
||||||
|
update work.lockcheck set a=2;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=Checking the lock was released,
|
||||||
|
outds=work.test_results
|
||||||
)
|
)
|
||||||
20
tests/base/mf_getgitbranch.test.sas
Normal file
20
tests/base/mf_getgitbranch.test.sas
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mf_getgitbranch.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getgitbranch.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* grab core repo */
|
||||||
|
%let gitdir=%sysfunc(pathname(work))/core;
|
||||||
|
%let repo=https://github.com/sasjs/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(&repo,&gitdir));
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_getgitbranch(&gitdir)=main),
|
||||||
|
desc=Checking correct branch was obtained,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
40
tests/base/mf_readfile.test.sas
Normal file
40
tests/base/mf_readfile.test.sas
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mf_readfile.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_readfile.sas
|
||||||
|
@li mf_writefile.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%let f=&sasjswork/myfile.txt;
|
||||||
|
|
||||||
|
%mf_writefile(&f,l1=some content,l2=more content)
|
||||||
|
data _null_;
|
||||||
|
infile "&f";
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=Check code ran without errors,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* test for scope leakage */
|
||||||
|
%global result;
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%put %mf_readfile(&f);
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
|
/* test result */
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_readfile(&f)=some content),
|
||||||
|
desc=Checking first line was ingested successfully,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
46
tests/base/mp_aligndecimal.test.sas
Normal file
46
tests/base/mp_aligndecimal.test.sas
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_aligndecimal macro
|
||||||
|
@details Creates an aligned variable and checks the number of leading blanks
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_aligndecimal.sas
|
||||||
|
@li mp_assertcolvals.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* target values */
|
||||||
|
data work.checkds;
|
||||||
|
do checkval=' 0.56',' 123.45',' 123.4 ',' 1.2 ',' 0';
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* raw values */
|
||||||
|
data work.rawds;
|
||||||
|
set work.checkds;
|
||||||
|
tgtvar=cats(checkval);
|
||||||
|
drop checkval;
|
||||||
|
run;
|
||||||
|
%mp_assertcolvals(work.rawds.tgtvar,
|
||||||
|
checkvals=work.checkds.checkval,
|
||||||
|
desc=No values match (ready to align),
|
||||||
|
test=NOVAL
|
||||||
|
)
|
||||||
|
|
||||||
|
/* aligned values */
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
data work.finalds;
|
||||||
|
set work.rawds;
|
||||||
|
%mp_aligndecimal(tgtvar,width=4)
|
||||||
|
run;
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
|
%mp_assertcolvals(work.finalds.tgtvar,
|
||||||
|
checkvals=work.checkds.checkval,
|
||||||
|
desc=All values match (aligned),
|
||||||
|
test=ALLVALS
|
||||||
|
)
|
||||||
@@ -7,23 +7,35 @@
|
|||||||
@li mp_assertcols.sas
|
@li mp_assertcols.sas
|
||||||
@li mp_assertcolvals.sas
|
@li mp_assertcolvals.sas
|
||||||
@li mp_assertdsobs.sas
|
@li mp_assertdsobs.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
/* valid filter */
|
/* make some data */
|
||||||
%mp_getcols(sashelp.airline,outds=work.info)
|
proc sql;
|
||||||
|
create table work.src(
|
||||||
|
SOME_DATETIME float format=datetime19.,
|
||||||
|
SOME_CHAR char(16),
|
||||||
|
SOME_NUM num,
|
||||||
|
SOME_TIME num format=time8.,
|
||||||
|
SOME_DATE num format=date9.
|
||||||
|
);
|
||||||
|
|
||||||
|
/* run macro, checking for scope leakage */
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%mp_getcols(work.src,outds=work.info)
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
%mp_assertdsobs(work.info,
|
%mp_assertdsobs(work.info,
|
||||||
desc=Has 3 records,
|
desc=Has 5 records,
|
||||||
test=EQUALS 3,
|
test=EQUALS 5,
|
||||||
outds=work.test_results
|
outds=work.test_results
|
||||||
)
|
)
|
||||||
|
|
||||||
data work.check;
|
data work.check;
|
||||||
length val $10;
|
length val $10;
|
||||||
do val='NUMERIC','DATE','CHARACTER';
|
do val='NUMERIC','DATE','CHARACTER','DATETIME','TIME';
|
||||||
output;
|
output;
|
||||||
end;
|
end;
|
||||||
run;
|
run;
|
||||||
|
|||||||
53
tests/base/mp_gitadd.test.sas
Normal file
53
tests/base/mp_gitadd.test.sas
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_gitadd.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_deletefile.sas
|
||||||
|
@li mf_writefile.sas
|
||||||
|
@li mp_gitadd.sas
|
||||||
|
@li mp_gitstatus.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* clone the source repo */
|
||||||
|
%let dir = %sysfunc(pathname(work))/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(https://github.com/sasjs/core,&dir));
|
||||||
|
|
||||||
|
/* add a file */
|
||||||
|
%mf_writefile(&dir/somefile.txt,l1=some content)
|
||||||
|
/* change a file */
|
||||||
|
%mf_writefile(&dir/readme.md,l1=new readme)
|
||||||
|
/* delete a file */
|
||||||
|
%mf_deletefile(&dir/package.json)
|
||||||
|
|
||||||
|
/* Run git status */
|
||||||
|
%mp_gitstatus(&dir,outds=work.gitstatus)
|
||||||
|
|
||||||
|
%let test1=0;
|
||||||
|
proc sql noprint;
|
||||||
|
select count(*) into: test1 from work.gitstatus where staged='FALSE';
|
||||||
|
|
||||||
|
/* should be three unstaged changes now */
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&test1=3),
|
||||||
|
desc=3 changes are ready to add,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* add them */
|
||||||
|
%mp_gitadd(&dir,inds=work.gitstatus,mdebug=&sasjs_mdebug)
|
||||||
|
|
||||||
|
/* check status */
|
||||||
|
%mp_gitstatus(&dir,outds=work.gitstatus2)
|
||||||
|
%let test2=0;
|
||||||
|
proc sql noprint;
|
||||||
|
select count(*) into: test2 from work.gitstatus2 where staged='TRUE';
|
||||||
|
|
||||||
|
/* should be three staged changes now */
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&test2=3),
|
||||||
|
desc=3 changes were added,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
32
tests/base/mp_gitlog.test.sas
Normal file
32
tests/base/mp_gitlog.test.sas
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_gitlog.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_nobs.sas
|
||||||
|
@li mp_gitlog.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* grab core repo */
|
||||||
|
%let gitdir=%sysfunc(pathname(work))/core;
|
||||||
|
%let repo=https://github.com/sasjs/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(&repo,&gitdir));
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%mp_gitlog(&gitdir,outds=work.test1)
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=Regular test works,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(work.test1)>1000),
|
||||||
|
desc=output has gt 1000 rows,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
30
tests/base/mp_gitreleaseinfo.test.sas
Normal file
30
tests/base/mp_gitreleaseinfo.test.sas
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_gitreleaseinfo.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_gitreleaseinfo.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
%mp_gitreleaseinfo(github,sasjs/core,outlib=mylibref,mdebug=1)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=mp_gitreleaseinfo runs without errors,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
set mylibref.author;
|
||||||
|
putlog (_all_)(=);
|
||||||
|
call symputx('author',login);
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&author=sasjsbot),
|
||||||
|
desc=release info extracted successfully,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
39
tests/base/mp_gitstatus.test.sas
Normal file
39
tests/base/mp_gitstatus.test.sas
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_gitstatus.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_deletefile.sas
|
||||||
|
@li mf_writefile.sas
|
||||||
|
@li mp_gitstatus.sas
|
||||||
|
@li mp_assertdsobs.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* clone the source repo */
|
||||||
|
%let dir = %sysfunc(pathname(work))/core;
|
||||||
|
%put source clone rc=%sysfunc(GITFN_CLONE(https://github.com/sasjs/core,&dir));
|
||||||
|
|
||||||
|
%mp_gitstatus(&dir,outds=work.gitstatus)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=Initial mp_gitstatus runs without errors,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* should be empty as there are no changes yet */
|
||||||
|
%mp_assertdsobs(work.gitstatus,test=EMPTY)
|
||||||
|
|
||||||
|
/* add a file */
|
||||||
|
%mf_writefile(&dir/somefile.txt,l1=some content)
|
||||||
|
/* change a file */
|
||||||
|
%mf_writefile(&dir/readme.md,l1=new readme)
|
||||||
|
/* delete a file */
|
||||||
|
%mf_deletefile(&dir/package.json)
|
||||||
|
|
||||||
|
/* re-run git status */
|
||||||
|
%mp_gitstatus(&dir,outds=work.gitstatus)
|
||||||
|
|
||||||
|
/* should be three changes now */
|
||||||
|
%mp_assertdsobs(work.gitstatus,test=EQUALS 3)
|
||||||
@@ -131,3 +131,19 @@ data _null_;
|
|||||||
set work.hashes2;
|
set work.hashes2;
|
||||||
put file_hash file_path;
|
put file_hash file_path;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
/* check that it works when the target directory is missing */
|
||||||
|
|
||||||
|
%mp_hashdirectory(&fpath/doesnotexist,outds=work.hashes3,maxdepth=MAX)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=No errors when directory is missing,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(work.hashes3)=0),
|
||||||
|
desc=no records created when directory is missing,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
231
tests/base/mp_loadformat.test.1.sas
Normal file
231
tests/base/mp_loadformat.test.1.sas
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_loadformat.sas macro
|
||||||
|
@details first test regular formats, then informats
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mddl_dc_difftable.sas
|
||||||
|
@li mp_aligndecimal.sas
|
||||||
|
@li mp_cntlout.sas
|
||||||
|
@li mp_loadformat.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* prep format catalog */
|
||||||
|
libname perm (work);
|
||||||
|
|
||||||
|
%mddl_dc_difftable(libds=perm.audit)
|
||||||
|
|
||||||
|
/* set up regular formats */
|
||||||
|
data work.loadfmts;
|
||||||
|
/* matching start / end lengths (to baseds) are important */
|
||||||
|
length fmtname $32 start end $10000;
|
||||||
|
eexcl='Y';
|
||||||
|
type='N';
|
||||||
|
do i=1 to 10;
|
||||||
|
fmtname=cats('SASJS_',put(i,z4.),'X');
|
||||||
|
do j=1 to 20;
|
||||||
|
start=cats(j);
|
||||||
|
end=cats(j+1);
|
||||||
|
%mp_aligndecimal(start,width=16)
|
||||||
|
%mp_aligndecimal(end,width=16)
|
||||||
|
label= cats('Numeric Format ',start);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
proc format cntlin=work.loadfmts library=perm.testcat;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/*
|
||||||
|
use actual format data as test baseline, as proc format adds attributes eg
|
||||||
|
min/max etc
|
||||||
|
*/
|
||||||
|
%mp_cntlout(libcat=perm.testcat,cntlout=work.loadfmts2)
|
||||||
|
|
||||||
|
/* make some test data */
|
||||||
|
data work.stagedata;
|
||||||
|
set work.loadfmts2 end=lastobs;
|
||||||
|
by type fmtname;
|
||||||
|
|
||||||
|
if lastobs then do;
|
||||||
|
output;
|
||||||
|
fmtname='NEWFMT'!!cats(_n_,'x'); /* 1 new record */
|
||||||
|
start=cats(_n_);
|
||||||
|
end=cats(_n_+1);
|
||||||
|
%mp_aligndecimal(start,width=16)
|
||||||
|
%mp_aligndecimal(end,width=16)
|
||||||
|
label='newval'!!cats(_N_,'X');
|
||||||
|
output;
|
||||||
|
stop;
|
||||||
|
end;
|
||||||
|
else if last.fmtname then deleteme='Yes'; /* 9 deletions */
|
||||||
|
else if first.fmtname then label='modified '!!cats(_n_); /* 10 changes */
|
||||||
|
|
||||||
|
output;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* load the above */
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%mp_loadformat(perm.testcat
|
||||||
|
,work.stagedata
|
||||||
|
,loadtarget=YES
|
||||||
|
,auditlibds=perm.audit
|
||||||
|
,locklibds=0
|
||||||
|
,delete_col=deleteme
|
||||||
|
,outds_add=add_test1
|
||||||
|
,outds_del=del_test1
|
||||||
|
,outds_mod=mod_test1
|
||||||
|
,mdebug=1
|
||||||
|
)
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(del_test1)=9),
|
||||||
|
desc=Test 1 - delete obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(add_test1)=1),
|
||||||
|
desc=Test 1 - add obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(mod_test1)=10),
|
||||||
|
desc=Test 1 - mod obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(perm.audit)=440),
|
||||||
|
desc=Test 1 - audit table updated,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
data work.difftest;
|
||||||
|
set perm.audit;
|
||||||
|
where is_diff=1;
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(work.difftest)>0),
|
||||||
|
desc=Test 1 - diffs were found,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* set up a mix of formats */
|
||||||
|
data work.loadfmts3;
|
||||||
|
length fmtname $32 start end $10000;
|
||||||
|
eexcl='Y';
|
||||||
|
type='J';
|
||||||
|
do i=1 to 3;
|
||||||
|
fmtname=cats('SASJS_CI_',i,'X');
|
||||||
|
do j=1 to 4;
|
||||||
|
start=cats(j);
|
||||||
|
end=start;
|
||||||
|
label= cats('Char INFORMAT ',start);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
type='I';
|
||||||
|
do i=1 to 3;
|
||||||
|
fmtname=cats('SASJS_NI_',i,'X');
|
||||||
|
do j=1 to 4;
|
||||||
|
start=cats(j);
|
||||||
|
end=cats(j+1);
|
||||||
|
%mp_aligndecimal(start,width=16)
|
||||||
|
%mp_aligndecimal(end,width=16)
|
||||||
|
label= cats(ranuni(0));
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
type='N';
|
||||||
|
do i=1 to 3;
|
||||||
|
fmtname=cats('SASJS_NF_',i,'X');
|
||||||
|
do j=1 to 4;
|
||||||
|
start=cats(j);
|
||||||
|
end=cats(j+1);
|
||||||
|
%mp_aligndecimal(start,width=16)
|
||||||
|
%mp_aligndecimal(end,width=16)
|
||||||
|
label= cats('Numeric Format ',start);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
type='C';
|
||||||
|
do i=1 to 3;
|
||||||
|
fmtname=cats('SASJS_CF_',i,'X');
|
||||||
|
do j=1 to 4;
|
||||||
|
start=cats(j);
|
||||||
|
end=start;
|
||||||
|
label= cats('Char Format ',start);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
drop i j;
|
||||||
|
run;
|
||||||
|
proc format cntlin=work.loadfmts3 library=perm.testcat3;
|
||||||
|
run;
|
||||||
|
%mp_cntlout(libcat=perm.testcat3,cntlout=work.loadfmts4)
|
||||||
|
|
||||||
|
/* make some test data */
|
||||||
|
data work.stagedata3;
|
||||||
|
set work.loadfmts4;
|
||||||
|
where type in ('I','J');
|
||||||
|
by type fmtname notsorted;
|
||||||
|
if type='I' then do;
|
||||||
|
if last.fmtname then do;
|
||||||
|
deleteme='Yes'; /* 3 deletions */
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
else if fmtrow le 3 then do; /* 9 changed values */
|
||||||
|
z=ranuni(0)*1000000;
|
||||||
|
start=cats(z);
|
||||||
|
end=cats(z+1);
|
||||||
|
%mp_aligndecimal(start,width=16)
|
||||||
|
%mp_aligndecimal(end,width=16)
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
else do;
|
||||||
|
if last.fmtname then do;
|
||||||
|
output; /* 6 new records */
|
||||||
|
x=_n_;
|
||||||
|
x+1;start=cats("mod",x);end=start;label='newlabel1';output;
|
||||||
|
x+1;start=cats("mod",x);end=start;label='newlabel2';output;
|
||||||
|
end;
|
||||||
|
else if fmtrow le 3 then do; /* 9 more changed values */
|
||||||
|
start= cats("mod",_n_);
|
||||||
|
end=start;
|
||||||
|
label= "mod "||cats(ranuni(0)*100);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_loadformat(perm.testcat3
|
||||||
|
,work.stagedata3
|
||||||
|
,loadtarget=YES
|
||||||
|
,auditlibds=perm.audit
|
||||||
|
,locklibds=0
|
||||||
|
,delete_col=deleteme
|
||||||
|
,outds_add=add_test2
|
||||||
|
,outds_del=del_test2
|
||||||
|
,outds_mod=mod_test2
|
||||||
|
,mdebug=1
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(del_test2)=3),
|
||||||
|
desc=Test 2 - delete obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(mod_test2)=18),
|
||||||
|
desc=Test 2 - mod obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(add_test2)=6),
|
||||||
|
desc=Test 2 - add obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
123
tests/base/mp_loadformat.test.2.sas
Normal file
123
tests/base/mp_loadformat.test.2.sas
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_loadformat.sas macro for multilabel formats
|
||||||
|
@details Multilabel records can be complete duplicates!! Also, the order is
|
||||||
|
important.
|
||||||
|
|
||||||
|
The provided formats create a table as follows:
|
||||||
|
|
||||||
|
|
||||||
|
|TYPE:$1.|FMTNAME:$32.|START:$10000.|END:$10000.|LABEL:$32767.|MIN:best.|MAX:best.|DEFAULT:best.|LENGTH:best.|FUZZ:best.|PREFIX:$2.|MULT:best.|FILL:$1.|NOEDIT:best.|SEXCL:$1.|EEXCL:$1.|HLO:$13.|DECSEP:$1.|DIG3SEP:$1.|DATATYPE:$8.|LANGUAGE:$8.|
|
||||||
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||
|
|`C `|`GENDERML `|` `|` `|`Total people `|`1 `|`40 `|`12 `|`12 `|`0 `|` `|`0 `|` `|`0 `|`N `|`N `|`M `|` `|` `|` `|` `|
|
||||||
|
|`C `|`GENDERML `|`1 `|`1 `|`Male `|`1 `|`40 `|`12 `|`12 `|`0 `|` `|`0 `|` `|`0 `|`N `|`N `|`M `|` `|` `|` `|` `|
|
||||||
|
|`C `|`GENDERML `|`1 `|`1 `|`Total people `|`1 `|`40 `|`12 `|`12 `|`0 `|` `|`0 `|` `|`0 `|`N `|`N `|`M `|` `|` `|` `|` `|
|
||||||
|
|`C `|`GENDERML `|`2 `|`2 `|`Female `|`1 `|`40 `|`12 `|`12 `|`0 `|` `|`0 `|` `|`0 `|`N `|`N `|`M `|` `|` `|` `|` `|
|
||||||
|
|`C `|`GENDERML `|`2 `|`2 `|`Female `|`1 `|`40 `|`12 `|`12 `|`0 `|` `|`0 `|` `|`0 `|`N `|`N `|`M `|` `|` `|` `|` `|
|
||||||
|
|`C `|`GENDERML `|`2 `|`2 `|`Thormale `|`1 `|`40 `|`12 `|`12 `|`0 `|` `|`0 `|` `|`0 `|`N `|`N `|`M `|` `|` `|` `|` `|
|
||||||
|
|`C `|`GENDERML `|`2 `|`2 `|`Total people `|`1 `|`40 `|`12 `|`12 `|`0 `|` `|`0 `|` `|`0 `|`N `|`N `|`M `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLA `|`1 `|`4 `|`Preschool `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLA `|`1 `|`18 `|`Children `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLA `|`19 `|`120 `|`Adults `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLB `|`1 `|`4 `|`Preschool `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLB `|`1 `|`18 `|`Children `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLB `|`19 `|`120 `|`Adults `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLC `|`1 `|`18 `|`Children `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLC `|`1 `|`4 `|`Preschool `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|`N `|`AGEMLC `|`19 `|`120 `|`Adults `|`1 `|`40 `|`9 `|`9 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`SM `|` `|` `|` `|` `|
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_nobs.sas
|
||||||
|
@li mp_cntlout.sas
|
||||||
|
@li mp_loadformat.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertdsobs.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* prep format catalog */
|
||||||
|
libname perm (work);
|
||||||
|
|
||||||
|
/* create some multilable formats */
|
||||||
|
%let cat1=perm.test1;
|
||||||
|
proc format library=&cat1;
|
||||||
|
value $genderml (multilabel notsorted)
|
||||||
|
'1'='Male'
|
||||||
|
'2'='Female'
|
||||||
|
'2'='Female'
|
||||||
|
'2'='Farmale'
|
||||||
|
'1','2',' '='Total people';
|
||||||
|
value agemla (multilabel)
|
||||||
|
1-4='Preschool'
|
||||||
|
1-18='Children'
|
||||||
|
19-120='Adults';
|
||||||
|
value agemlb (multilabel)
|
||||||
|
19-120='Adults'
|
||||||
|
1-18='Children'
|
||||||
|
1-4='Preschool';
|
||||||
|
value agemlc (multilabel notsorted)
|
||||||
|
19-120='Adults'
|
||||||
|
1-18='Children'
|
||||||
|
1-4='Preschool';
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_cntlout(libcat=&cat1,cntlout=work.cntlout1)
|
||||||
|
%mp_assertdsobs(work.cntlout1,
|
||||||
|
desc=Has 16 records,
|
||||||
|
test=EQUALS 16
|
||||||
|
)
|
||||||
|
|
||||||
|
data work.stagedata3;
|
||||||
|
set work.cntlout1;
|
||||||
|
if fmtname='AGEMLA' and label ne 'Preschool' then deleteme='Yes';
|
||||||
|
if fmtname='AGEMLB' and label = 'Preschool' then label='Kids';
|
||||||
|
if fmtname='GENDERML' and label='Farmale' then output;
|
||||||
|
output;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
%mp_loadformat(&cat1
|
||||||
|
,work.stagedata3
|
||||||
|
,loadtarget=YES
|
||||||
|
,auditlibds=perm.audit
|
||||||
|
,locklibds=0
|
||||||
|
,delete_col=deleteme
|
||||||
|
,outds_add=add_test1
|
||||||
|
,outds_del=del_test1
|
||||||
|
,outds_mod=mod_test1
|
||||||
|
,mdebug=1
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(del_test1)=2),
|
||||||
|
desc=Test 1 - deleted obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(mod_test1)=4),
|
||||||
|
desc=Test 1 - mod obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(add_test1)=1),
|
||||||
|
desc=Test 1 - add obs,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* now check the order of the notsorted format */
|
||||||
|
%mp_cntlout(libcat=&cat1,cntlout=work.cntlout2)
|
||||||
|
|
||||||
|
%let check1=0;
|
||||||
|
%let check2=0;
|
||||||
|
data test;
|
||||||
|
set work.cntlout2;
|
||||||
|
where fmtname='GENDERML';
|
||||||
|
if _n_=4 and label='Farmale' then call symputx('check1',1);
|
||||||
|
if _n_=5 and label='Farmale' then call symputx('check2',1);
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&check1=1 and &check2=1),
|
||||||
|
desc=Ensuring Farmale values retain their order,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
/**
|
|
||||||
@file
|
|
||||||
@brief Testing mp_loadformat.sas macro
|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
|
||||||
@li mddl_dc_difftable.sas
|
|
||||||
@li mp_loadformat.sas
|
|
||||||
@li mp_assert.sas
|
|
||||||
@li mp_assertscope.sas
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
/* prep format catalog */
|
|
||||||
libname perm (work);
|
|
||||||
|
|
||||||
%mddl_dc_difftable(libds=perm.audit)
|
|
||||||
|
|
||||||
data work.loadfmts;
|
|
||||||
length fmtname $32;
|
|
||||||
eexcl='Y';
|
|
||||||
type='N';
|
|
||||||
do i=1 to 100;
|
|
||||||
fmtname=cats('SASJS_',i,'X');
|
|
||||||
do j=1 to 100;
|
|
||||||
start=cats(j);
|
|
||||||
end=cats(j+1);
|
|
||||||
label= cats('Dummy ',start);
|
|
||||||
output;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
run;
|
|
||||||
proc format cntlin=work.loadfmts library=perm.testcat;
|
|
||||||
run;
|
|
||||||
|
|
||||||
/* make some test data */
|
|
||||||
data work.stagedata;
|
|
||||||
set work.loadfmts;
|
|
||||||
type='N';
|
|
||||||
eexcl='Y';
|
|
||||||
if _n_<150 then deleteme='Yes';
|
|
||||||
else if _n_<250 then label='mod'!!cats(_n_);
|
|
||||||
else if _n_<350 then do;
|
|
||||||
start=cats(_n_);
|
|
||||||
end=cats(_n_+1);
|
|
||||||
label='newval'!!cats(_N_);
|
|
||||||
end;
|
|
||||||
else stop;
|
|
||||||
run;
|
|
||||||
|
|
||||||
/* load the above */
|
|
||||||
%mp_assertscope(SNAPSHOT)
|
|
||||||
%mp_loadformat(perm.testcat
|
|
||||||
,work.stagedata
|
|
||||||
,loadtarget=YES
|
|
||||||
,auditlibds=perm.audit
|
|
||||||
,locklibds=0
|
|
||||||
,delete_col=deleteme
|
|
||||||
,outds_add=add_test1
|
|
||||||
,outds_del=del_test1
|
|
||||||
,outds_mod=mod_test1
|
|
||||||
,mdebug=1
|
|
||||||
)
|
|
||||||
%mp_assertscope(COMPARE)
|
|
||||||
|
|
||||||
%mp_assert(
|
|
||||||
iftrue=(%mf_nobs(del_test1)=149),
|
|
||||||
desc=Test 1 - delete obs,
|
|
||||||
outds=work.test_results
|
|
||||||
)
|
|
||||||
%mp_assert(
|
|
||||||
iftrue=(%mf_nobs(add_test1)=100),
|
|
||||||
desc=Test 1 - add obs,
|
|
||||||
outds=work.test_results
|
|
||||||
)
|
|
||||||
%mp_assert(
|
|
||||||
iftrue=(%mf_nobs(mod_test1)=100),
|
|
||||||
desc=Test 1 - mod obs,
|
|
||||||
outds=work.test_results
|
|
||||||
)
|
|
||||||
%mp_assert(
|
|
||||||
iftrue=(%mf_nobs(perm.audit)=7329),
|
|
||||||
desc=Test 1 - audit table updated,
|
|
||||||
outds=work.test_results
|
|
||||||
)
|
|
||||||
data work.difftest;
|
|
||||||
set perm.audit;
|
|
||||||
where is_diff=1;
|
|
||||||
run;
|
|
||||||
%mp_assert(
|
|
||||||
iftrue=(%mf_nobs(work.difftest)>0),
|
|
||||||
desc=Test 1 - diffs were found,
|
|
||||||
outds=work.test_results
|
|
||||||
)
|
|
||||||
@@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_lockanytable.sas
|
@li mp_lockanytable.sas
|
||||||
|
@li mp_assert.sas
|
||||||
@li mp_assertcols.sas
|
@li mp_assertcols.sas
|
||||||
@li mp_assertcolvals.sas
|
@li mp_assertcolvals.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
@li mp_coretable.sas
|
@li mp_coretable.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@@ -61,3 +63,18 @@ run;
|
|||||||
desc=Ref is captured in unlock,
|
desc=Ref is captured in unlock,
|
||||||
test=ANYVAL
|
test=ANYVAL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* attempt unlock of a table that was never locked */
|
||||||
|
|
||||||
|
%mp_lockanytable(UNLOCK,lib=no,ds=doesnotexist,ref=bye, ctl_ds=work.controller)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=Ability to unlock a table that was never locked,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* test for macro variable scope leakage */
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%mp_lockanytable(LOCK,lib=tmp,ds=testscope,ref=This Ref, ctl_ds=work.controller)
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
@brief Testing mv_jobflow macro
|
@brief Testing mv_jobflow macro
|
||||||
@details One of the remote jobs aborts with syscc>0 - test to
|
@details One of the remote jobs aborts with syscc>0 - test to
|
||||||
make sure this comes back to the calling session
|
make sure this comes back to the calling session
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_assert.sas
|
@li mp_assert.sas
|
||||||
@li mv_createjob.sas
|
@li mv_createjob.sas
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
@brief Testing mv_jobflow macro
|
@brief Testing mv_jobflow macro
|
||||||
@details All jobs complete successfully with syscc = 0 - test to
|
@details All jobs complete successfully with syscc = 0 - test to
|
||||||
make sure this comes back to the calling session
|
make sure this comes back to the calling session
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_assert.sas
|
@li mp_assert.sas
|
||||||
@li mv_createjob.sas
|
@li mv_createjob.sas
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
@brief Testing mv_registerclient.sas macro
|
@brief Testing mv_registerclient.sas macro
|
||||||
@details Tests for successful registration. For this to work, the test
|
@details Tests for successful registration. For this to work, the test
|
||||||
account must be an admin.
|
account must be an admin.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquename.sas
|
@li mf_getuniquename.sas
|
||||||
@li mp_assertcolvals.sas
|
@li mp_assertcolvals.sas
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
|
|
||||||
@file
|
@file
|
||||||
@brief Testing mv_registerclient.sas macro
|
@brief Testing mv_registerclient.sas macro
|
||||||
@details Tests for unsuccessful registration. To do this, overrides are
|
@details Tests for unsuccessful registration. To do this, overrides are
|
||||||
applied for the mf_loc.sas and mp_abort.sas macros.
|
applied for the mf_loc.sas and mp_abort.sas macros.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_assert.sas
|
@li mp_assert.sas
|
||||||
@li mv_registerclient.sas
|
@li mv_registerclient.sas
|
||||||
|
|||||||
60
viya/mfv_existsashdat.sas
Normal file
60
viya/mfv_existsashdat.sas
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
@file mfv_existsashdat.sas
|
||||||
|
@brief Checks whether a CAS sashdat dataset exists in persistent storage.
|
||||||
|
@details Can be used in open code, eg as follows:
|
||||||
|
|
||||||
|
%if %mfv_existsashdat(libds=casuser.sometable) %then %put yes it does!;
|
||||||
|
|
||||||
|
The function uses `dosubl()` to run the `table.fileinfo` action, for the
|
||||||
|
specified library, filtering for `*.sashdat` tables. The results are stored
|
||||||
|
in a WORK table (&outprefix._&lib). If that table already exists, it is
|
||||||
|
queried instead, to avoid the dosubl() performance hit.
|
||||||
|
|
||||||
|
To force a rescan, just use a new `&outprefix` value, or delete the table(s)
|
||||||
|
before running the function.
|
||||||
|
|
||||||
|
@param libds library.dataset
|
||||||
|
@param outprefix= (work.mfv_existsashdat) Used to store the current HDATA
|
||||||
|
tables to improve subsequent query performance. This reference is a prefix
|
||||||
|
and is converted to `&prefix._{libref}`
|
||||||
|
|
||||||
|
@return output returns 1 or 0
|
||||||
|
|
||||||
|
@version 0.2
|
||||||
|
@author Mathieu Blauw
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mfv_existsashdat(libds,outprefix=work.mfv_existsashdat
|
||||||
|
);
|
||||||
|
%local rc dsid name lib ds;
|
||||||
|
%let lib=%upcase(%scan(&libds,1,'.'));
|
||||||
|
%let ds=%upcase(%scan(&libds,-1,'.'));
|
||||||
|
|
||||||
|
/* if table does not exist, create it */
|
||||||
|
%if %sysfunc(exist(&outprefix._&lib)) ne 1 %then %do;
|
||||||
|
%let rc=%sysfunc(dosubl(%nrstr(
|
||||||
|
/* Read in table list (once per &lib per session) */
|
||||||
|
proc cas;
|
||||||
|
table.fileinfo result=source_list /caslib="&lib";
|
||||||
|
val=findtable(source_list);
|
||||||
|
saveresult val dataout=&outprefix._&lib;
|
||||||
|
quit;
|
||||||
|
/* Only keep name, without file extension */
|
||||||
|
data &outprefix._&lib;
|
||||||
|
set &outprefix._&lib(where=(Name like '%.sashdat') keep=Name);
|
||||||
|
Name=upcase(scan(Name,1,'.'));
|
||||||
|
run;
|
||||||
|
)));
|
||||||
|
%end;
|
||||||
|
|
||||||
|
/* Scan table for hdat existence */
|
||||||
|
%let dsid=%sysfunc(open(&outprefix._&lib(where=(name="&ds"))));
|
||||||
|
%syscall set(dsid);
|
||||||
|
%let rc = %sysfunc(fetch(&dsid));
|
||||||
|
%let rc = %sysfunc(close(&dsid));
|
||||||
|
|
||||||
|
/* Return result */
|
||||||
|
%if "%trim(&name)"="%trim(&ds)" %then 1;
|
||||||
|
%else 0;
|
||||||
|
|
||||||
|
%mend mfv_existsashdat;
|
||||||
@@ -743,7 +743,25 @@ data _null_;
|
|||||||
put ' put '',"SYS_JES_JOB_URI" : '' SYS_JES_JOB_URI ; ';
|
put ' put '',"SYS_JES_JOB_URI" : '' SYS_JES_JOB_URI ; ';
|
||||||
put ' put ",""SYSJOBID"" : ""&sysjobid"" "; ';
|
put ' put ",""SYSJOBID"" : ""&sysjobid"" "; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
put ' syserrortext=cats(''"'',tranwrd(symget(''syserrortext''),''"'',''\"''),''"''); ';
|
put ' syserrortext=cats(symget(''syserrortext'')); ';
|
||||||
|
put ' if findc(syserrortext,''"\''!!''0A0D09000E0F010210111A''x) then do; ';
|
||||||
|
put ' syserrortext=''"''!!trim( ';
|
||||||
|
put ' prxchange(''s/"/\\"/'',-1, /* double quote */ ';
|
||||||
|
put ' prxchange(''s/\x0A/\n/'',-1, /* new line */ ';
|
||||||
|
put ' prxchange(''s/\x0D/\r/'',-1, /* carriage return */ ';
|
||||||
|
put ' prxchange(''s/\x09/\\t/'',-1, /* tab */ ';
|
||||||
|
put ' prxchange(''s/\x00/\\u0000/'',-1, /* NUL */ ';
|
||||||
|
put ' prxchange(''s/\x0E/\\u000E/'',-1, /* SS */ ';
|
||||||
|
put ' prxchange(''s/\x0F/\\u000F/'',-1, /* SF */ ';
|
||||||
|
put ' prxchange(''s/\x01/\\u0001/'',-1, /* SOH */ ';
|
||||||
|
put ' prxchange(''s/\x02/\\u0002/'',-1, /* STX */ ';
|
||||||
|
put ' prxchange(''s/\x10/\\u0010/'',-1, /* DLE */ ';
|
||||||
|
put ' prxchange(''s/\x11/\\u0011/'',-1, /* DC1 */ ';
|
||||||
|
put ' prxchange(''s/\x1A/\\u001A/'',-1, /* SUB */ ';
|
||||||
|
put ' prxchange(''s/\\/\\\\/'',-1,syserrortext) ';
|
||||||
|
put ' )))))))))))))!!''"''; ';
|
||||||
|
put ' end; ';
|
||||||
|
put ' else syserrortext=cats(''"'',syserrortext,''"''); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
||||||
put ' put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" "; ';
|
put ' put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" "; ';
|
||||||
@@ -756,7 +774,25 @@ data _null_;
|
|||||||
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
||||||
put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
|
put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
|
||||||
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
||||||
put ' syswarningtext=cats(''"'',tranwrd(symget(''syswarningtext''),''"'',''\"''),''"''); ';
|
put ' syswarningtext=cats(symget(''syswarningtext'')); ';
|
||||||
|
put ' if findc(syswarningtext,''"\''!!''0A0D09000E0F010210111A''x) then do; ';
|
||||||
|
put ' syswarningtext=''"''!!trim( ';
|
||||||
|
put ' prxchange(''s/"/\\"/'',-1, /* double quote */ ';
|
||||||
|
put ' prxchange(''s/\x0A/\n/'',-1, /* new line */ ';
|
||||||
|
put ' prxchange(''s/\x0D/\r/'',-1, /* carriage return */ ';
|
||||||
|
put ' prxchange(''s/\x09/\\t/'',-1, /* tab */ ';
|
||||||
|
put ' prxchange(''s/\x00/\\u0000/'',-1, /* NUL */ ';
|
||||||
|
put ' prxchange(''s/\x0E/\\u000E/'',-1, /* SS */ ';
|
||||||
|
put ' prxchange(''s/\x0F/\\u000F/'',-1, /* SF */ ';
|
||||||
|
put ' prxchange(''s/\x01/\\u0001/'',-1, /* SOH */ ';
|
||||||
|
put ' prxchange(''s/\x02/\\u0002/'',-1, /* STX */ ';
|
||||||
|
put ' prxchange(''s/\x10/\\u0010/'',-1, /* DLE */ ';
|
||||||
|
put ' prxchange(''s/\x11/\\u0011/'',-1, /* DC1 */ ';
|
||||||
|
put ' prxchange(''s/\x1A/\\u001A/'',-1, /* SUB */ ';
|
||||||
|
put ' prxchange(''s/\\/\\\\/'',-1,syswarningtext) ';
|
||||||
|
put ' )))))))))))))!!''"''; ';
|
||||||
|
put ' end; ';
|
||||||
|
put ' else syswarningtext=cats(''"'',syswarningtext,''"''); ';
|
||||||
put ' put '',"SYSWARNINGTEXT" : '' syswarningtext; ';
|
put ' put '',"SYSWARNINGTEXT" : '' syswarningtext; ';
|
||||||
put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''" ''; ';
|
put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''" ''; ';
|
||||||
put ' length memsize $32; ';
|
put ' length memsize $32; ';
|
||||||
|
|||||||
@@ -204,7 +204,25 @@
|
|||||||
put ',"SYS_JES_JOB_URI" : ' SYS_JES_JOB_URI ;
|
put ',"SYS_JES_JOB_URI" : ' SYS_JES_JOB_URI ;
|
||||||
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
syserrortext=cats('"',tranwrd(symget('syserrortext'),'"','\"'),'"');
|
syserrortext=cats(symget('syserrortext'));
|
||||||
|
if findc(syserrortext,'"\'!!'0A0D09000E0F010210111A'x) then do;
|
||||||
|
syserrortext='"'!!trim(
|
||||||
|
prxchange('s/"/\\"/',-1, /* double quote */
|
||||||
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
||||||
|
prxchange('s/\x0D/\r/',-1, /* carriage return */
|
||||||
|
prxchange('s/\x09/\\t/',-1, /* tab */
|
||||||
|
prxchange('s/\x00/\\u0000/',-1, /* NUL */
|
||||||
|
prxchange('s/\x0E/\\u000E/',-1, /* SS */
|
||||||
|
prxchange('s/\x0F/\\u000F/',-1, /* SF */
|
||||||
|
prxchange('s/\x01/\\u0001/',-1, /* SOH */
|
||||||
|
prxchange('s/\x02/\\u0002/',-1, /* STX */
|
||||||
|
prxchange('s/\x10/\\u0010/',-1, /* DLE */
|
||||||
|
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
|
||||||
|
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
|
||||||
|
prxchange('s/\\/\\\\/',-1,syserrortext)
|
||||||
|
)))))))))))))!!'"';
|
||||||
|
end;
|
||||||
|
else syserrortext=cats('"',syserrortext,'"');
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
||||||
put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" ";
|
put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" ";
|
||||||
@@ -217,7 +235,25 @@
|
|||||||
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
||||||
sysvlong=quote(trim(symget('sysvlong')));
|
sysvlong=quote(trim(symget('sysvlong')));
|
||||||
put ',"SYSVLONG" : ' sysvlong;
|
put ',"SYSVLONG" : ' sysvlong;
|
||||||
syswarningtext=cats('"',tranwrd(symget('syswarningtext'),'"','\"'),'"');
|
syswarningtext=cats(symget('syswarningtext'));
|
||||||
|
if findc(syswarningtext,'"\'!!'0A0D09000E0F010210111A'x) then do;
|
||||||
|
syswarningtext='"'!!trim(
|
||||||
|
prxchange('s/"/\\"/',-1, /* double quote */
|
||||||
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
||||||
|
prxchange('s/\x0D/\r/',-1, /* carriage return */
|
||||||
|
prxchange('s/\x09/\\t/',-1, /* tab */
|
||||||
|
prxchange('s/\x00/\\u0000/',-1, /* NUL */
|
||||||
|
prxchange('s/\x0E/\\u000E/',-1, /* SS */
|
||||||
|
prxchange('s/\x0F/\\u000F/',-1, /* SF */
|
||||||
|
prxchange('s/\x01/\\u0001/',-1, /* SOH */
|
||||||
|
prxchange('s/\x02/\\u0002/',-1, /* STX */
|
||||||
|
prxchange('s/\x10/\\u0010/',-1, /* DLE */
|
||||||
|
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
|
||||||
|
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
|
||||||
|
prxchange('s/\\/\\\\/',-1,syswarningtext)
|
||||||
|
)))))))))))))!!'"';
|
||||||
|
end;
|
||||||
|
else syswarningtext=cats('"',syswarningtext,'"');
|
||||||
put ',"SYSWARNINGTEXT" : ' syswarningtext;
|
put ',"SYSWARNINGTEXT" : ' syswarningtext;
|
||||||
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
||||||
length memsize $32;
|
length memsize $32;
|
||||||
|
|||||||
Reference in New Issue
Block a user