<jupyter_start><jupyter_text>Add Peer Grouping To Windows Host DataThis notebook introduces peer grouping - the idea that we can segment a network into smaller groups of similar devices / users / etc. This segmentation permits finer resolution of outliers.In this example, we break the notebook into two peer groups based on whether it is a `User` or a `Computer` account. Users correspond to actual users, computers to system accounts.__<NAME>__  __SAS Institute__  __[<EMAIL>](mailto:<EMAIL>)__<jupyter_code>import warnings
warnings.filterwarnings('ignore')

import os
import swat
import matplotlib.pyplot as plt
import numpy as np

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Standard getting started stuff:* set environment variables.* establish CAS connection.* set active CASLIB.* load our dataset.<jupyter_code>os.environ["CAS_CLIENT_SSL_CA_LIST"]="/home/ds/cascert.pem"

conn = swat.CAS("<your-CAS-server-url>", 5570)

conn.setsessopt('WH')

out = conn.loadtable('wls_day_02_hr13.sashdat', caslib='WH')<jupyter_output>NOTE: Cloud Analytic Services made the file wls_day_02_hr13.sashdat available as table WLS_DAY_02_HR13 in caslib CASUSER(daherr).<jupyter_text>This time, we'll add a column using datastep code.We'll rely on the conditional functionality to determine a peer group type.<jupyter_code>sasCode = F'''
    data wls_day_02_hr13_pg;
        set wls_day_02_hr13;
        if find(UserName, '$', 'i') then peerGroup = "Computers";
        else if find(UserName, 'User') then peerGroup = "Users";
        else peerGroup = "Computers";
'''

print(sasCode)
conn.datastep.runcode(sasCode)
conn.promote(name='wls_day_02_hr13_pg')
conn.fetch(table={'name':'wls_day_02_hr13_pg'}, maxrows=20)
conn.table.save(table='wls_day_02_hr13_pg', name='wls_day_02_hr13_pg.sashdat', caslib='WH', replace=True)
conn.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10444563470808785, 'fraction_numerical': 0.022495982860203535, 'mean_word_length': 6.157088122605364, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '628607', 'license': 'Apache-2.0', 'n_tokens_mistral': 660, 'n_tokens_neox': 621, 'n_words': 169, 'path': '3601-2019-Herrick/notebooks/04_AddPeerGrouping.ipynb', 'repo_name': 'dtherrick/sas-global-forum-2019', 'size': '1905'}