<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>PROC-X.com</title>
	<atom:link href="http://proc-x.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://proc-x.com</link>
	<description>An online (unofficial) SAS® journal - written by bloggers</description>
	<lastBuildDate>Wed, 01 Feb 2023 09:11:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9</generator>
	<item>
		<title>ChatGPT and SAS 9 Metadata Security</title>
		<link>http://proc-x.com/2023/02/chatgpt-and-sas-9-metadata-security/</link>
		
		<dc:creator><![CDATA[Paul Homes]]></dc:creator>
		<pubDate>Wed, 01 Feb 2023 09:11:45 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[OpenAI]]></category>
		<category><![CDATA[SAS 9.4]]></category>
		<category><![CDATA[SAS Metadata Security]]></category>
		<guid isPermaLink="false">https://platformadmin.com/blogs/paul/?p=6719</guid>

					<description><![CDATA[<p>With all the news around ChatGPT lately, I thought I would see how it performed when asked questions about SAS 9 Metadata Security. This is a niche specialty with some complex rules when you get down into the details, so I was not expecting it to do ve...</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2023/02/chatgpt-and-sas-9-metadata-security/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2023/02/chatgpt-and-sas-9-metadata-security/">ChatGPT and SAS 9 Metadata Security</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://platformadmin.com/blogs/paul/2023/02/chatgpt-and-sas-9-metadata-security/"> platformadmin.com</a> - go there to comment and to read  <a href="https://platformadmin.com/blogs/paul/2023/02/chatgpt-and-sas-9-metadata-security/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p>With all the news around ChatGPT lately, I thought I would see how it performed when asked questions about SAS 9 Metadata Security. This is a niche specialty with some complex rules when you get down into the details, so I was not expecting it to do very well. I was both impressed and disappointed. &#8230; <a href="https://platformadmin.com/blogs/paul/2023/02/chatgpt-and-sas-9-metadata-security/" class="more-link" ref="nofollow" target="_blank">Continue reading<span class="screen-reader-text"> &#8220;ChatGPT and SAS 9 Metadata Security&#8221;</span></a></p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://platformadmin.com/blogs/paul/2023/02/chatgpt-and-sas-9-metadata-security/"> platformadmin.com</a> - go there to comment and to read  <a href="https://platformadmin.com/blogs/paul/2023/02/chatgpt-and-sas-9-metadata-security/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2023/02/chatgpt-and-sas-9-metadata-security/">ChatGPT and SAS 9 Metadata Security</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="" length="0" type="" />

			</item>
		<item>
		<title>SAS 9.4 Maintenance 8 is available</title>
		<link>http://proc-x.com/2023/01/sas-9-4-maintenance-8-is-available/</link>
		
		<dc:creator><![CDATA[Chris hemedinger]]></dc:creator>
		<pubDate>Tue, 31 Jan 2023 14:00:31 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[SAS 9.4]]></category>
		<category><![CDATA[sas users]]></category>
		<category><![CDATA[Tech]]></category>
		<guid isPermaLink="false">https://blogs.sas.com/content/sgf/?p=44560</guid>

					<description><![CDATA[<p>SAS 9.4M8 is available. Its focus is on security and updates to third-party technologies. It also updates the supported OS environments.</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/31/sas94m8-announcement/">SAS 9.4 Maintenance 8 is available</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf">SAS Users</a>.</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2023/01/sas-9-4-maintenance-8-is-available/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2023/01/sas-9-4-maintenance-8-is-available/">SAS 9.4 Maintenance 8 is available</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/31/sas94m8-announcement/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/31/sas94m8-announcement/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p>SAS has released SAS 9.4 Maintenance 8, a major update to SAS 9.4. </p>
<p>Security is the primary focus of the Maintenance 8 update. This release contains updates for many of the third-party technologies that are used by the platform, including the Java runtime environment (JRE) and many of the third-party JAR files. This release also adds support for major releases of supported operating systems, while limiting support for operating systems that are no longer supported by their respective suppliers. My colleague Margaret Crevar has <a href="https://communities.sas.com/t5/Administration-and-Deployment/SAS-9-4-M8-is-now-available/m-p/856447" ref="nofollow" target="_blank">summarized these changes in this SAS Communities post</a>.</p>
<p>As with all SAS maintenance releases, this release &#8220;rolls up&#8221; the hotfixes and enhancements delivered since the last major update (SAS 9.4 Maintenance 7). Most SAS platform products and solutions have also been updated to remain compatible with this release and take advantage of enhancements. However, there are some products and solutions that will not be available immediately, or that will not deliver support for SAS 9.4 Maintenance 8.</p>
<p>Because SAS 9.4 Maintenance 8 is a major software release for SAS 9.4, it is <a href="https://support.sas.com/en/technical-support/services-policies.html" ref="nofollow" target="_blank">covered by the SAS Support policy</a> for the &#8220;Standard Support&#8221; timeframe according to its general availability date: Jan 31, 2023. (Current policy offers Standard Support for 5 years from the GA date.) </p>
<p>While this maintenance release doesn&#8217;t contain new features, it does demonstrate the commitment of SAS to support users of the SAS 9.4 platform for many years to come. (See &#8220;Your platform, your way&#8221; in &#8220;<a href="https://blogs.sas.com/content/sascom/2022/08/10/your-analytics-your-way/" ref="nofollow" target="_blank">Your analytics, your way</a>&#8221; from Shadi Shahin.) New data and analytics capabilities are delivered in the SAS Viya platform, <a href="https://communities.sas.com/t5/SAS-Viya-Release-Updates/tkb-p/releaseupdates" ref="nofollow" target="_blank">which offers monthly cadence releases</a> via its continuous delivery model.</p>
<p>For an overview of all product changes and updates in SAS 9.4 Maintenance 8, see <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/whatsdiff/upgradeswhatsnew94.htm" ref="nofollow" target="_blank">the What&#8217;s New topic in the SAS documentation</a>.</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/31/sas94m8-announcement/" ref="nofollow" target="_blank">SAS 9.4 Maintenance 8 is available</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf" ref="nofollow" target="_blank">SAS Users</a>.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/31/sas94m8-announcement/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/31/sas94m8-announcement/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2023/01/sas-9-4-maintenance-8-is-available/">SAS 9.4 Maintenance 8 is available</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://blogs.sas.com/content/sgf/files/2023/01/update-150x150.jpeg" length="0" type="" />

			</item>
		<item>
		<title>Getting started with Python integration to SAS® Viya® &#8211; Part 12 &#8211; Count of Unique Values</title>
		<link>http://proc-x.com/2023/01/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/</link>
		
		<dc:creator><![CDATA[Peter Styliadis]]></dc:creator>
		<pubDate>Tue, 17 Jan 2023 13:46:09 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[CAS]]></category>
		<category><![CDATA[CAS Action Sets]]></category>
		<category><![CDATA[CAS Actions]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[freq CAS action]]></category>
		<category><![CDATA[freqTab CAS action]]></category>
		<category><![CDATA[Programming Tips]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Python Integration to SAS Viya]]></category>
		<category><![CDATA[SAS programmers]]></category>
		<category><![CDATA[sas viya]]></category>
		<category><![CDATA[SAS Viya Programming]]></category>
		<category><![CDATA[SWAT]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[tips & techniques]]></category>
		<category><![CDATA[value_counts()]]></category>
		<guid isPermaLink="false">https://blogs.sas.com/content/sgf/?p=43741</guid>

					<description><![CDATA[<p>Welcome to the continuation of my series Getting Started with Python Integration to SAS Viya. In previous posts, I discussed how to connect to the CAS server, working with CAS actions and CASResults objects, and how to summarize columns. Now it's time to focus on how to get the count of unique values [...]</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/17/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/">Getting started with Python integration to SAS® Viya® - Part 12 - Count of Unique Values</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf">SAS Users</a>.</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2023/01/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2023/01/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/">Getting started with Python integration to SAS® Viya® – Part 12 – Count of Unique Values</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/17/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/17/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p>Welcome to the continuation of my series <a href="https://blogs.sas.com/content/sgf/2020/06/19/getting-started-with-python-integration-to-sas-viya-index/" rel="noopener" ref="nofollow" target="_blank">Getting Started with Python Integration to SAS Viya</a>. In previous posts, I discussed <a href="https://blogs.sas.com/content/sgf/2020/04/15/getting-started-with-python-integration-to-sas-viya-part-1-making-a-connection/" rel="noopener" ref="nofollow" target="_blank">how to connect to the CAS server</a>, <a href="https://blogs.sas.com/content/sgf/2020/06/19/getting-started-with-python-integration-to-sas-viya-part-2-working-with-cas-actions-and-casresults-objects/" rel="noopener" ref="nofollow" target="_blank">working with CAS actions and CASResults objects</a>, and how to <a href="https://blogs.sas.com/content/sgf/2022/09/14/getting-started-with-python-integration-to-sas-viya-part-9-summarize-columns/" rel="noopener" ref="nofollow" target="_blank">summarize columns</a>. Now it&#8217;s time to focus on how to get the count of unique values in a CAS table column.</p>
<h2>Load and prepare data</h2>
<p>First, I connected my Python client to the distributed CAS server and named my connection <strong>conn</strong>. Then I created a function to load and prepare my CAS table. The custom function loads the <strong>WARRANTY_CLAIMS_0117.sashdat</strong> file from the <strong>Samples</strong> caslib into memory, renames the columns using the column labels and drops unnecessary columns. This simplifies the table for the demonstration.</p>
<p>The <strong>Samples</strong> caslib should be available in your SAS Viya environment and contains sample tables. For more information on how to rename columns in a CAS table view <a href="https://blogs.sas.com/content/sgf/2022/10/13/getting-started-with-python-integration-to-sas-viya-part-11-rename-columns/" rel="noopener" ref="nofollow" target="_blank">Part 11 &#8211; Rename Columns.</a></p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">## Packages</span>
<span style="color: #ff7700;font-weight:bold;">import</span> swat
<span style="color: #ff7700;font-weight:bold;">import</span> pandas <span style="color: #ff7700;font-weight:bold;">as</span> pd
&nbsp;
<span style="color: #808080; font-style: italic;">## Options</span>
pd.<span style="color: black;">set_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'display.max_columns'</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">50</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">## Connect to CAS</span>
conn <span style="color: #66cc66;">=</span> <span style="color: #808080; font-style: italic;">## your connection information</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> prep_data<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #808080; font-style: italic;">## Load the data into CAS</span>
    conn.<span style="color: black;">loadTable</span><span style="color: black;">&#40;</span>path<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'WARRANTY_CLAIMS_0117.sashdat'</span><span style="color: #66cc66;">,</span> caslib<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'samples'</span><span style="color: #66cc66;">,</span>
                   casout<span style="color: #66cc66;">=</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">'name'</span>:<span style="color: #483d8b;">'warranty_claims'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'caslib'</span>:<span style="color: #483d8b;">'casuser'</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">## Reference the CAS table in an object</span>
    castbl <span style="color: #66cc66;">=</span> conn.<span style="color: black;">CASTable</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'warranty_claims'</span><span style="color: #66cc66;">,</span> caslib <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'casuser'</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">## Store the column names and labels in a dataframe</span>
    df_col_names <span style="color: #66cc66;">=</span> castbl.<span style="color: black;">columnInfo</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'ColumnInfo'</span><span style="color: black;">&#93;</span>.<span style="color: black;">loc</span><span style="color: black;">&#91;</span>:<span style="color: #66cc66;">,</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'Column'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Label'</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">## Create a list of dictionaries of how to rename each column using the column labels</span>
    renameColumns <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> row <span style="color: #ff7700;font-weight:bold;">in</span> df_col_names.<span style="color: black;">iterrows</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        colName <span style="color: #66cc66;">=</span> row<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">values</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
        labelName <span style="color: #66cc66;">=</span> row<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">values</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">' '</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'_'</span><span style="color: black;">&#41;</span>
        renameColumns.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">dict</span><span style="color: black;">&#40;</span>name<span style="color: #66cc66;">=</span>colName<span style="color: #66cc66;">,</span> rename<span style="color: #66cc66;">=</span>labelName<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">## List of columns to keep in the CAS table</span>
    keepColumns <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">'Campaign_Type'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Platform'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Trim_Level'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Make'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Model_Year'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Engine_Model'</span><span style="color: #66cc66;">,</span>
                   <span style="color: #483d8b;">'Vehicle_Assembly_Plant'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Claim_Repair_Start_Date'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Claim_Repair_End_Date'</span><span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">## Rename and drop columns to make the table easier to use</span>
    castbl.<span style="color: black;">alterTable</span><span style="color: black;">&#40;</span>columns <span style="color: #66cc66;">=</span> renameColumns<span style="color: #66cc66;">,</span> keep <span style="color: #66cc66;">=</span> keepColumns<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">return</span> castbl</pre>
</td>
</tr>
</table>
</div>
<p>Next, I&#8217;ll execute the user defined function and store the CAS table object in the variable <strong>tbl  </strong>and view it&#8217;s type.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;">tbl <span style="color: #66cc66;">=</span> prep_data<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #008000;">type</span><span style="color: black;">&#40;</span>tbl<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># and the results</span>
NOTE: Cloud Analytic Services made the <span style="color: #008000;">file</span> WARRANTY_CLAIMS_0117.<span style="color: black;">sashdat</span> available <span style="color: #ff7700;font-weight:bold;">as</span> table WARRANTY_CLAIMS <span style="color: #ff7700;font-weight:bold;">in</span> caslib CASUSER<span style="color: black;">&#40;</span>Peter<span style="color: black;">&#41;</span>.
<span style="color: black;">swat</span>.<span style="color: black;">cas</span>.<span style="color: black;">table</span>.<span style="color: black;">CASTable</span></pre>
</td>
</tr>
</table>
</div>
<p>The results show that the <strong>WARRANTY_CLAIMS_0117.sashdat</strong> is available in the CAS server, and <strong>tbl</strong> is a CASTable object.</p>
<p>Lastly, I&#8217;ll preview the distributed CAS table using the SWAT package head method.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;">tbl.<span style="color: black;">head</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/warranty_preview.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone wp-image-43812 size-full" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/warranty_preview.png?resize=560%2C102&#038;ssl=1" alt="" width="560" height="102" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/warranty_preview.png?resize=560%2C102&#038;ssl=1 1154w, https://blogs.sas.com/content/sgf/files/2022/12/warranty_preview-300x55.png 300w, https://blogs.sas.com/content/sgf/files/2022/12/warranty_preview-1024x187.png 1024w, https://blogs.sas.com/content/sgf/files/2022/12/warranty_preview-768x140.png 768w" sizes="(max-width: 1154px) 100vw, 1154px" data-recalc-dims="1" /></a></p>
<p>The results show a preview of the <strong>WARRANTY_CLAIMS</strong> CAS table. The table provides data on warranty claims for car repairs. The data in this example is small for training purposes. Processing data in the CAS server&#8217;s <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/casfun/n00001sascassrvmgt00000admin.htm" rel="noopener" ref="nofollow" target="_blank">massively parallel processing environment</a> is typically reserved for larger data.</p>
<h2>Using the Pandas API in the SWAT package &#8211; value_counts method</h2>
<p>I&#8217;ll begin by using the Pandas API in the SWAT package which provides the <a href="https://sassoftware.github.io/python-swat/generated/swat.cas.table.CASColumn.value_counts.html#" rel="noopener" ref="nofollow" target="_blank">value_counts</a> method. The value_counts method works like it&#8217;s Pandas counterpart. For example, I&#8217;ll obtain the count of unique values in the <strong>Engine_Model</strong> CAS table column. I&#8217;ll store the results of in <strong>vc</strong>, then display the type and value of <strong>vc</strong>.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;">vc <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span>tbl               <span style="color: #808080; font-style: italic;">## CAS table</span>
      .<span style="color: black;">Engine_Model</span>     <span style="color: #808080; font-style: italic;">## CAS table column</span>
      .<span style="color: black;">value_counts</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>   <span style="color: #808080; font-style: italic;">## SWAT value_counts method</span>
     <span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">## Display the type and value</span>
display<span style="color: black;">&#40;</span><span style="color: #008000;">type</span><span style="color: black;">&#40;</span>vc<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>vc<span style="color: black;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/value_counts.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone wp-image-43821 size-full" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/value_counts-e1671463887489.png?resize=237%2C120&#038;ssl=1" alt="" width="237" height="120" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/value_counts-e1671463887489.png?resize=237%2C120&#038;ssl=1 237w, https://blogs.sas.com/content/sgf/files/2022/12/value_counts-e1671463887489-164x82.png 164w" sizes="(max-width: 237px) 100vw, 237px" data-recalc-dims="1" /></a></p>
<p>The SWAT value_counts method summarizes the data in the distributed CAS server and returns a Pandas Series to the Python client. Once you have the Pandas Series on the client, you can work with it as you normally would. For example, I&#8217;ll plot the Series using the Pandas plot method.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;">vc.<span style="color: black;">plot</span><span style="color: black;">&#40;</span>kind <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'bar'</span><span style="color: #66cc66;">,</span> figsize<span style="color: #66cc66;">=</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">8</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">6</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/plot_series.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone size-full wp-image-43854" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/plot_series.png?resize=560%2C442&#038;ssl=1" alt="" width="560" height="442" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/plot_series.png?resize=560%2C442&#038;ssl=1 564w, https://blogs.sas.com/content/sgf/files/2022/12/plot_series-300x237.png 300w" sizes="(max-width: 564px) 100vw, 564px" data-recalc-dims="1" /></a></p>
<p>In this example, I used the Pandas API in the SWAT package to summarize data on the CAS server&#8217;s massively parallel processing environment to return smaller, summarized results to the Python client. Once the summarized results are on the client, I&#8217;ll work with them using other Python packages like Pandas.</p>
<h2>Using the freq CAS action</h2>
<p>Instead of using the Pandas API in the SWAT package you can achieve similar results using native CAS actions. In SWAT, CAS actions are simply specified as a method. One action that provides the count of unique values is the <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/casanpg/cas-simple-freq.htm?fromDefault=" rel="noopener" ref="nofollow" target="_blank">simple.freq</a> CAS action.</p>
<p>For example, I can find the count of unique values for multiple columns within the freq action. Here, I&#8217;ll specify the <strong>Engine_Model</strong>, <strong>Model_Year</strong> and <strong>Campaign_Type</strong> columns in the the inputs parameter. Then, I&#8217;ll call the <em>Frequency</em> key after the action to obtain the SASDataFrame stored in the dictionary returned to the Python client. Remember, CAS actions always return a dictionary, or CASResults object, to the Python client. You must use familiar dictionary manipulation techniques to work with the results of an action. For more information on working with results of CAS actions, check out <a href="https://blogs.sas.com/content/sgf/2020/06/19/getting-started-with-python-integration-to-sas-viya-part-2-working-with-cas-actions-and-casresults-objects/" rel="noopener" ref="nofollow" target="_blank">Part 2 &#8211; Working with CAS Actions and CASResults Objects</a>.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">## Columns to analyze</span>
colNames <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #483d8b;">'Engine_Model'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Model_Year'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Campaign_Type'</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">## Execute the freq CAS action and store the SASDataFrame</span>
freq_df <span style="color: #66cc66;">=</span> tbl.<span style="color: black;">freq</span><span style="color: black;">&#40;</span>inputs <span style="color: #66cc66;">=</span> colNames<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'Frequency'</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">## Display the type and DataFrame</span>
display<span style="color: black;">&#40;</span><span style="color: #008000;">type</span><span style="color: black;">&#40;</span>freq_df<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> freq_df<span style="color: black;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freq-CAS-action.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone size-full wp-image-43872" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freq-CAS-action.png?resize=419%2C528&#038;ssl=1" alt="" width="419" height="528" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freq-CAS-action.png?resize=419%2C528&#038;ssl=1 419w, https://blogs.sas.com/content/sgf/files/2022/12/freq-CAS-action-238x300.png 238w" sizes="(max-width: 419px) 100vw, 419px" data-recalc-dims="1" /></a></p>
<p>Again, the action processes the data in the distributed CAS server and returns results to the Python client. The results show the freq action counts the unique values of each column and stores the results in a single SASDataFrame. Once you have the SASDataFrame on the client, you can work with it like you would a Pandas DataFrame.</p>
<p>For example, I&#8217;ll loop over each analysis column, query the SASDataFrame for the specific column name, and then plot the count of unique values of each column using the familiar Pandas package.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">for</span> column <span style="color: #ff7700;font-weight:bold;">in</span> colNames:
    <span style="color: black;">&#40;</span>freq_df
     .<span style="color: black;">query</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Column == @column'</span><span style="color: black;">&#41;</span>
     .<span style="color: black;">loc</span><span style="color: black;">&#91;</span>:<span style="color: #66cc66;">,</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'CharVar'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Frequency'</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>
     .<span style="color: black;">set_index</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'CharVar'</span><span style="color: black;">&#41;</span>
     .<span style="color: black;">sort_values</span><span style="color: black;">&#40;</span>by <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'Frequency'</span><span style="color: #66cc66;">,</span> ascending<span style="color: #66cc66;">=</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
     .<span style="color: black;">plot</span><span style="color: black;">&#40;</span>kind<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'bar'</span><span style="color: #66cc66;">,</span> figsize<span style="color: #66cc66;">=</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">8</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">6</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> title <span style="color: #66cc66;">=</span> f<span style="color: #483d8b;">'The {column} Column'</span><span style="color: black;">&#41;</span>
    <span style="color: black;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/pandas_loop-1.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone size-large wp-image-43899" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/pandas_loop-1-438x1024.png?resize=438%2C1024&#038;ssl=1" alt="" width="438" height="1024" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/pandas_loop-1-438x1024.png?resize=438%2C1024&#038;ssl=1 438w, https://blogs.sas.com/content/sgf/files/2022/12/pandas_loop-1-128x300.png 128w, https://blogs.sas.com/content/sgf/files/2022/12/pandas_loop-1.png 485w" sizes="(max-width: 438px) 100vw, 438px" data-recalc-dims="1" /></a></p>
<p>The loop produces a visualization of the count of unique values for each analysis column. This was all done using familiar Pandas code on the client side. Remember, the distributed CAS server did all of the processing and summarization, then returned smaller summarized results to the Python client.</p>
<h2>Using the freqTab CAS action</h2>
<p>Lastly, you can use the <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/casactstat/cas-freqtab-freqtab.htm" rel="noopener" ref="nofollow" target="_blank">freqTab.freqTab</a> CAS action to construct frequency and crosstabulation tables. The freqTab action provides a variety of additional features and information. The action is not loaded by default, so I&#8217;ll begin by loading the action set.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;">conn.<span style="color: black;">loadActionSet</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'freqTab'</span><span style="color: black;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freqTab-action-set.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone size-full wp-image-43905" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freqTab-action-set.png?resize=334%2C63&#038;ssl=1" alt="" width="334" height="63" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freqTab-action-set.png?resize=334%2C63&#038;ssl=1 334w, https://blogs.sas.com/content/sgf/files/2022/12/freqTab-action-set-300x57.png 300w" sizes="(max-width: 334px) 100vw, 334px" data-recalc-dims="1" /></a></p>
<p>Then I&#8217;ll use the freqTab action in the freqTab action set to count the unique values for the <strong>Model_Year</strong> and <strong>Engine_Model</strong> columns, and also count the unique values of <strong>Engine_Model</strong> by <strong>Model_Year</strong>.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;">tbl.<span style="color: black;">freqTab</span><span style="color: black;">&#40;</span>tabulate <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span>
                <span style="color: #483d8b;">'Model_Year'</span><span style="color: #66cc66;">,</span>
                <span style="color: #483d8b;">'Engine_Model'</span><span style="color: #66cc66;">,</span>
                <span style="color: black;">&#123;</span><span style="color: #483d8b;">'vars'</span>:<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Engine_Model'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Model_Year'</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span>
            <span style="color: black;">&#93;</span>
    <span style="color: black;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freqTab-action.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone wp-image-43914 size-full" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freqTab-action.png?resize=560%2C1110&#038;ssl=1" alt="" width="560" height="1110" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/freqTab-action.png?resize=560%2C1110&#038;ssl=1 808w, https://blogs.sas.com/content/sgf/files/2022/12/freqTab-action-151x300.png 151w, https://blogs.sas.com/content/sgf/files/2022/12/freqTab-action-516x1024.png 516w, https://blogs.sas.com/content/sgf/files/2022/12/freqTab-action-768x1523.png 768w, https://blogs.sas.com/content/sgf/files/2022/12/freqTab-action-775x1536.png 775w" sizes="(max-width: 808px) 100vw, 808px" data-recalc-dims="1" /></a></p>
<p>The results above show the freqTab action returns a dictionary with a variety of information. The first SASDataFrame is level information, the second SASDataFrame shows the number of observations used, and the remaining SASDataFrames show the two one-way frequency tables for <b>Model_Year</b>, and <b>Engine_Model, </b>and the crosstabulation between<b> Engine_Model </b>by <b>Model_Year</b> (also includes the totals).</p>
<p>With the results on the Python client, you can begin accessing and manipulating the SASDataFrames as needed.</p>
<h2>Summary</h2>
<p>The SWAT package blends the world of Pandas and CAS. You can use many of the familiar Pandas methods within the SWAT package like value_counts, or the flexible, highly optimized CAS actions like simple.freq and freqTab.freqTab to obtain counts of unique values in the massively parallel processing CAS engine. For more examples on the freq or freqTab CAS actions, check out my CAS action four part series (<a href="https://blogs.sas.com/content/sgf/2022/12/07/cas-action-simple-frequency-tables-part-1/" rel="noopener" ref="nofollow" target="_blank">part 1</a>, <a href="https://blogs.sas.com/content/sgf/2022/12/12/cas-action-saving-frequency-tables-part-2/" rel="noopener" ref="nofollow" target="_blank">part 2</a>, <a href="https://blogs.sas.com/content/sgf/2022/12/16/cas-action-grouping-frequency-tables-part-3/" rel="noopener" ref="nofollow" target="_blank">part 3</a> and <a href="https://blogs.sas.com/content/sgf/2022/12/19/cas-action-advanced-frequency-tables-part-4/" rel="noopener" ref="nofollow" target="_blank">part 4</a>). The four part series executes CAS actions using the native CAS language. However, with some small changes to the syntax you can execute the same actions using Python.</p>
<h2>Additional and related resources</h2>
<ul>
<li><a href="https://blogs.sas.com/content/sgf/2020/06/19/getting-started-with-python-integration-to-sas-viya-index/" rel="noopener" ref="nofollow" target="_blank">Getting Started with Python Integration to SAS® Viya® &#8211; Index</a></li>
<li><a href="https://sassoftware.github.io/python-swat/api.html" rel="noopener" ref="nofollow" target="_blank">SWAT API Reference</a></li>
<li><a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/casanpg/cas-simple-freq.htm" rel="noopener" ref="nofollow" target="_blank">simple.freq CAS action</a></li>
<li><a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/casactstat/cas-freqtab-freqtab.htm" rel="noopener" ref="nofollow" target="_blank">freqTab.freqTab CAS action</a></li>
<li><a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/casfun/titlepage.htm?homeOnFail" rel="noopener" ref="nofollow" target="_blank">SAS® Cloud Analytic Services: Fundamentals</a></li>
<li><a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/allprodsactions/actionsByName.htm" rel="noopener" ref="nofollow" target="_blank">CAS Action Documentation</a></li>
<li><a href="https://blogs.sas.com/content/sgf/2021/08/06/cas-action-a-series-on-fundamentals/" rel="noopener" ref="nofollow" target="_blank">CAS Action! &#8211; a series on fundamentals</a></li>
<li>SAS Course &#8211; <a href="https://support.sas.com/edu/schedules.html?crs=PIVY&amp;ctry=US" rel="noopener" ref="nofollow" target="_blank">SAS® Viya® and Python Integration Fundamentals </a></li>
</ul>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/17/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/" ref="nofollow" target="_blank">Getting started with Python integration to SAS® Viya® &#8211; Part 12 &#8211; Count of Unique Values</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf" ref="nofollow" target="_blank">SAS Users</a>.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/17/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/17/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2023/01/getting-started-with-python-integration-to-sas-viya-part-12-count-of-unique-values/">Getting started with Python integration to SAS® Viya® – Part 12 – Count of Unique Values</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://blogs.sas.com/content/sgf/files/2020/06/SAS-Viya-CAS-150x150.jpg" length="0" type="" />

			</item>
		<item>
		<title>Automatic cloning of SAS metadata user groups and roles</title>
		<link>http://proc-x.com/2023/01/automatic-cloning-of-sas-metadata-user-groups-and-roles/</link>
		
		<dc:creator><![CDATA[Leonid Batkhan]]></dc:creator>
		<pubDate>Wed, 11 Jan 2023 12:00:44 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[Metadata]]></category>
		<category><![CDATA[SAS Administrators]]></category>
		<category><![CDATA[SAS programmers]]></category>
		<category><![CDATA[Tech]]></category>
		<guid isPermaLink="false">https://blogs.sas.com/content/sgf/?p=44277</guid>

					<description><![CDATA[<p>SAS expert Leonid Batkhan demonstrates how to automatically replicate/clone metadata users’ groups and roles from one user to another.</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/11/automatic-cloning-of-sas-metadata-user-groups-and-roles/">Automatic cloning of SAS metadata user groups and roles</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf">SAS Users</a>.</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2023/01/automatic-cloning-of-sas-metadata-user-groups-and-roles/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2023/01/automatic-cloning-of-sas-metadata-user-groups-and-roles/">Automatic cloning of SAS metadata user groups and roles</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/11/automatic-cloning-of-sas-metadata-user-groups-and-roles/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/11/automatic-cloning-of-sas-metadata-user-groups-and-roles/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p><img class="alignright size-medium wp-image-44286" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2023/01/user-groups-cloning.jpg?fit=300%2C300&#038;ssl=1" alt="Cloning SAS metadata user groups" width="300" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2023/01/user-groups-cloning.jpg?fit=300%2C300&#038;ssl=1 600w, https://blogs.sas.com/content/sgf/files/2023/01/user-groups-cloning-300x200.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" data-recalc-dims="1" /><br />
In this blog post, we tackle automating the <a href="https://support.sas.com/en/documentation/install-center/94/intelligence-platform.html" ref="nofollow" target="_blank">SAS Intelligence Platform</a> administrator’s task of replicating (cloning) metadata users’ groups and roles from one user to another.</p>
<p>As more people become new SAS users or move to new projects or teams, their data and applications access credentials need to be set up or modified in SAS Metadata. In this scenario, a typical request to SAS platform administrators looks like one of the following:</p>
<ul>
<li>Add Mr. A Smith as SAS user and make him a member of the groups and roles matching those of Ms. B. Brown.</li>
<li>For an existing SAS user Mr. A. Smith, replace his memberships of the groups and roles to mimic those of Ms. B. Brown.</li>
<li>For an existing SAS user Mr. A. Smith, add to his memberships of the groups and roles those that are missing from those of Ms. B. Brown.</li>
</ul>
<p>SAS administrators routinely fulfill such requests by manually clicking through SAS Users plug-in in SAS Management Console. However, when a number of groups/roles to assign becomes rather large, this seemingly straightforward process can become overwhelming and error-prone.</p>
<p>Let&#8217;s change the conventional practice of manually replicating group memberships from one user to another. Let&#8217;s do it programmatically, which will make it easy, repeatable, fast, consistent, efficient and reliable.</p>
<h2>Using SAS metadata functions to GET user-group associations</h2>
<p>While you can employ <a href="https://blogs.sas.com/content/sgf/2016/01/13/sas-administrators-tip-keeping-track-of-sas-users/" ref="nofollow" target="_blank">macro %MDUEXTR</a> to produce a list of groups for metadata users, here we are going to dive deeper and implement this task by using <a href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrmeta/p02e3ara4110hcn1dei1tun4smmu.htm" ref="nofollow" target="_blank">SAS data step metadata functions</a>.</p>
<p>First, we connect to the SAS metadata server:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #006400; font-style: italic;">/* Connect to the SAS metadata server */</span>
<span style="color: #0000ff;">options</span>
   metaserver = <span style="color: #a020f0;">'your_metadata_server'</span>
   metaport = <span style="color: #2e8b57; font-weight: bold;">8561</span>
   metarepository = Foundation
   metauser = <span style="color: #a020f0;">'sasadm@saspw'</span>
   metapass = <span style="color: #a020f0;">'{SAS002}encrypted_password'</span>
   ;
<span style="color: #0000ff;">Then</span>, let’s <span style="color: #000080; font-weight: bold;">run</span> the following code:
<span style="color: #006400; font-style: italic;">/* User Name (not Display Name) */</span> 
<span style="color: #0000ff;">%let</span> user_name = B Brown;
&nbsp;
<span style="color: #000080; font-weight: bold;">data</span> USER_GROUPS;
   <span style="color: #0000ff;">length</span> UserName UserURI GroupURI GroupName GroupDisplayName $256;
   <span style="color: #0000ff;">call</span> <span style="color: #0000ff;">missing</span><span style="color: #66cc66;">&#40;</span>of _char_<span style="color: #66cc66;">&#41;</span>;
   UserName = <span style="color: #a020f0;">&quot;&amp;user_name&quot;</span>;
   UserURI = <span style="color: #a020f0;">&quot;omsobj:Person?@Name='&amp;user_name'&quot;</span>; 
   <span style="color: #0000ff;">do</span> j=<span style="color: #2e8b57; font-weight: bold;">1</span> <span style="color: #0000ff;">by</span> <span style="color: #2e8b57; font-weight: bold;">1</span> <span style="color: #0000ff;">while</span><span style="color: #66cc66;">&#40;</span>metadata_getnasn<span style="color: #66cc66;">&#40;</span>UserURI, <span style="color: #a020f0;">'IdentityGroups'</span>, j, GroupURI<span style="color: #66cc66;">&#41;</span>&gt;<span style="color: #2e8b57; font-weight: bold;">0</span><span style="color: #66cc66;">&#41;</span>;
      rc = metadata_getattr<span style="color: #66cc66;">&#40;</span>GroupURI, <span style="color: #a020f0;">'Name'</span>, GroupName<span style="color: #66cc66;">&#41;</span>; 
      rc = metadata_getattr<span style="color: #66cc66;">&#40;</span>GroupURI, <span style="color: #a020f0;">'DisplayName'</span>, GroupDisplayName<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #0000ff;">output</span>; 
   <span style="color: #0000ff;">end</span>;
<span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<h3 style="color: #1e40eb">Code highlights</h3>
<p>In this code, we loop through user’s groups while the following condition is <em>true</em>:</p>
<p><tt>metadata_getnasn(UserURI, 'IdentityGroups', j, GroupURI) &gt; 0</tt></p>
<p>It is important to realize that <a href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrmeta/p1kjy5liyi86w8n1vfopazyeb70u.htm" ref="nofollow" target="_blank">function METADATA_GETNASN</a> returns two values. Besides its return value (number of associated objects) referenced by the function itself, its 4-th argument (GroupURI) also returns a value of the j-th associated object of the specified association (&#8216;IdentityGroups&#8217;) for the specified object (UserURI).  When j becomes greater than the number of groups associated with the user, this function returns value of -4 ( “j is out of range” ) which effectively stops further iterations of the do-loop.</p>
<p>Within the do-loop, we use <a href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrmeta/p1kjy5liyi86w8n1vfopazyeb70u.htm" ref="nofollow" target="_blank">function METADATA_GETATTR</a> which returns the value (GroupName) of the specified attribute (&#8216;Name&#8217;) for the specified object (GroupURI). Successful completion is indicated by its return value rc=0.</p>
<p>Similarly, the second call of the METADATA_GETATTR function returns GroupDisplayName.</p>
<h3 style="color: #1e40eb">Output</h3>
<p>As a result, we are going to get the following USER_GROUPS table:</p>
<p><img loading="lazy" width="560" height="79" class="alignnone size-full wp-image-44289" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2023/01/user-goups-listing.jpg?resize=560%2C79&#038;ssl=1" alt="Metadata user groups inventory" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2023/01/user-goups-listing.jpg?resize=560%2C79&#038;ssl=1 1462w, https://blogs.sas.com/content/sgf/files/2023/01/user-goups-listing-300x42.jpg 300w, https://blogs.sas.com/content/sgf/files/2023/01/user-goups-listing-1024x145.jpg 1024w, https://blogs.sas.com/content/sgf/files/2023/01/user-goups-listing-768x109.jpg 768w" sizes="(max-width: 1462px) 100vw, 1462px" data-recalc-dims="1" /></p>
<h2>Using SAS metadata functions to SET user-group associations</h2>
<p>Analogous to retrieving user groups associations using METADATA_GETNASN function, we can SET (or assign) such associations using <a href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrmeta/p1pt2ddn2xhmaen1p5whdq58ithh.htm" ref="nofollow" target="_blank">METADATA_SETASSN function</a>.  For example, the following statement will modify existing list of members for the group referenced by the first argument (pguri) by adding a new user referenced by the 4-th argument (curi):</p>
<p><tt>rc = metadata_setassn(pguri, 'MemberIdentities', 'Merge',curi);</tt></p>
<h2>SAS macro to automatically clone group memberships from one user to another</h2>
<p>Now, let’s cut all the exploratory code and wrap everything together into a little nice macro:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">%macro</span> mm_clone_user_groups 
   <span style="color: #66cc66;">&#40;</span>
   child_name=,  <span style="color: #006400; font-style: italic;">/* Child's User Name (not a Display Name)                   */</span>
   parent_name=, <span style="color: #006400; font-style: italic;">/* Parent's User Name (not a Display Name)                  */</span>
   <span style="color: #0000ff;">mod</span>=<span style="color: #0000ff;">ADD</span>       <span style="color: #006400; font-style: italic;">/* Modifier (optional, values – ADD or Replace, default=ADD */</span>
   <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000080; font-weight: bold;">data</span> <span style="color: #0000ff;">_null_</span>;
   <span style="color: #0000ff;">length</span> curi cguri puri pguri $256;
   <span style="color: #0000ff;">call</span> <span style="color: #0000ff;">missing</span><span style="color: #66cc66;">&#40;</span>of _char_<span style="color: #66cc66;">&#41;</span>;
   curi = <span style="color: #a020f0;">&quot;omsobj:Person?@Name='&amp;child_name'&quot;</span>;  <span style="color: #006400; font-style: italic;">/* Child's URI  */</span>
   puri = <span style="color: #a020f0;">&quot;omsobj:Person?@Name='&amp;parent_name'&quot;</span>; <span style="color: #006400; font-style: italic;">/* Parent's URI */</span>
&nbsp;
   <span style="color: #006400; font-style: italic;">/* Conditionally remove existing Child's Groups */</span>
   <span style="color: #0000ff;">if</span> <span style="color: #0000ff;">upcase</span><span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">&quot;&amp;mod&quot;</span><span style="color: #66cc66;">&#41;</span>=<span style="color: #a020f0;">&quot;REPLACE&quot;</span> <span style="color: #0000ff;">then</span>
   <span style="color: #006400; font-style: italic;">/* Loop through Child's Groups */</span>
   <span style="color: #0000ff;">do</span> i=<span style="color: #2e8b57; font-weight: bold;">1</span> <span style="color: #0000ff;">by</span> <span style="color: #2e8b57; font-weight: bold;">1</span> <span style="color: #0000ff;">while</span><span style="color: #66cc66;">&#40;</span>metadata_getnasn<span style="color: #66cc66;">&#40;</span>curi,<span style="color: #a020f0;">'IdentityGroups'</span>,i,cguri<span style="color: #66cc66;">&#41;</span>&gt;<span style="color: #2e8b57; font-weight: bold;">0</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #006400; font-style: italic;">/* Remove Child User from each Child's Group */</span> 
      rc = metadata_setassn<span style="color: #66cc66;">&#40;</span>cguri,<span style="color: #a020f0;">'MemberIdentities'</span>,<span style="color: #a020f0;">'Remove'</span>,curi<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #0000ff;">end</span>;
&nbsp;
   <span style="color: #006400; font-style: italic;">/* Loop through Parent's Groups */</span>
   <span style="color: #0000ff;">do</span> j=<span style="color: #2e8b57; font-weight: bold;">1</span> <span style="color: #0000ff;">by</span> <span style="color: #2e8b57; font-weight: bold;">1</span> <span style="color: #0000ff;">while</span><span style="color: #66cc66;">&#40;</span>metadata_getnasn<span style="color: #66cc66;">&#40;</span>puri,<span style="color: #a020f0;">'IdentityGroups'</span>,j,pguri<span style="color: #66cc66;">&#41;</span>&gt;<span style="color: #2e8b57; font-weight: bold;">0</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #006400; font-style: italic;">/* Add Child User to each Parent's Group */</span> 
      rc = metadata_setassn<span style="color: #66cc66;">&#40;</span>pguri,<span style="color: #a020f0;">'MemberIdentities'</span>,<span style="color: #a020f0;">'Merge'</span>,curi<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #0000ff;">end</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
&nbsp;
<span style="color: #0000ff;">%mend</span> mm_clone_user_groups;</pre>
</td>
</tr>
</table>
</div>
<h3 style="color: #1e40eb">Code highlights</h3>
<p>The first do-loop executes conditionally only when Modifier is REPLACE (case-insensitive). It iterates through all the groups that child user belongs to and remove that child user from each such a group. Please note that <em>removing</em> a user from a group’s “Current Members” list is equivalent to removing this group from the user’s “Member of” list.</p>
<p>Similarly, <em>adding</em> a group to a user’s “Member of” list is equivalent to adding this user to the group’s “Current Members” list. We use this fact in the second do-loop when for each group associated with the parent we add the child as the group member.</p>
<p>Unless we need to report on the groups we are “cloning” from the parent, we may skip capturing their attributes (like Name or Display Name) using METADATA_GETATTR function as we did in the previous section.</p>
<h3 style="color: #1e40eb">Macro usage</h3>
<p>Here are a couple examples of the macro invocation:</p>
<h4 style="text-decoration: underline"><strong>Example 1</strong></h4>
<p><tt>%mm_clone_user_groups(child_name=A. Smith, parent_name=B Brown, mod=replace)</tt></p>
<p>In this example, the macro will remove all the child’s group associations and replace them by those of the parent user.</p>
<h4 style="text-decoration: underline"><strong>Example 2</strong></h4>
<p><tt>%mm_clone_user_groups(child_name=A. Smith, parent_name=B Brown)</tt></p>
<p>Here, by default mod=ADD and the macro will <em>augment</em> the child’s group associations by those of the parent user.</p>
<p>Note, that these two examples cover all three scenarios of the group membership cloning outlined in the beginning of this post.</p>
<h2>Acknowledgement</h2>
<p>Great thanks to Carl Sommer of SAS Technical Support for his invaluable assistance and guidance in navigating through the SAS metadata functions and metadata object associations.</p>
<h2>Questions? Thoughts? Comments?</h2>
<p>Do you find this blog post useful? How do you administer user group identities/memberships in SAS metadata? Do you have questions, concerns, suggestions, or comments? Please share with us below in the Comments section.</p>
<h2>Additional Resources</h2>
<ul>
<li><a href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2610-2018.pdf" ref="nofollow" target="_blank">Metadata management &#8211; Building Blocks</a></li>
<li><a href="https://blogs.sas.com/content/sgf/2016/01/13/sas-administrators-tip-keeping-track-of-sas-users/" ref="nofollow" target="_blank">SAS administrators tip: Keeping track of SAS users</a></li>
<li><a href="https://platformadmin.com/blogs/paul/2020/03/duplicating-copying-sas-users/" ref="nofollow" target="_blank">Duplicating or Copying SAS Users</a></li>
<li><a href="https://core.sasjs.io/dir_0d92069d5a23b1d3125c326d74f1a07c.html" ref="nofollow" target="_blank">SASjs MacroCore Library: Metadata Aware Macros</a></li>
</ul>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/11/automatic-cloning-of-sas-metadata-user-groups-and-roles/" ref="nofollow" target="_blank">Automatic cloning of SAS metadata user groups and roles</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf" ref="nofollow" target="_blank">SAS Users</a>.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/11/automatic-cloning-of-sas-metadata-user-groups-and-roles/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/11/automatic-cloning-of-sas-metadata-user-groups-and-roles/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2023/01/automatic-cloning-of-sas-metadata-user-groups-and-roles/">Automatic cloning of SAS metadata user groups and roles</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://blogs.sas.com/content/sgf/files/2023/01/user-groups-cloning-150x150.jpg" length="0" type="" />

			</item>
		<item>
		<title>What is SAS Viya?</title>
		<link>http://proc-x.com/2023/01/what-is-sas-viya/</link>
		
		<dc:creator><![CDATA[Susan Slaughter]]></dc:creator>
		<pubDate>Wed, 11 Jan 2023 00:40:41 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Guest Blog]]></category>
		<guid isPermaLink="false">http://susanslaughter.wordpress.com/?p=2594</guid>

					<description><![CDATA[<p>I asked Matthew Slaughter to briefly explain what SAS Viya is. Here is his answer: There are many different products marketed under the label of “Viya,” and it’s not always clear how they relate to each other or how SAS Viya is different from previous versions of SAS. In a nutshell, SAS Viya is the […]</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2023/01/what-is-sas-viya/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2023/01/what-is-sas-viya/">What is SAS Viya?</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://susanslaughter.wordpress.com/2023/01/10/what-is-sas-viya/"> Avocet Solutions</a> - go there to comment and to read  <a href="https://susanslaughter.wordpress.com/2023/01/10/what-is-sas-viya/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p>I asked Matthew Slaughter to briefly explain what <a href="https://www.sas.com/en_us/software/viya.html" rel="noopener" ref="nofollow" target="_blank">SAS Viya</a> is. Here is his answer:</p>
<p>There are many different products marketed under the label of “Viya,” and it’s not always clear how they relate to each other or how SAS Viya is different from previous versions of SAS. In a nutshell, <span style="color: #800000"><strong>SAS Viya is the version of SAS which runs on CAS</strong></span>. This begs the next question….</p>
<p><span style="color: #800000"><strong>What is CAS?</strong></span></p>
<p>CAS stands for “Cloud Analytic Services” and is the name of a massively parallel-processing platform for fast in-memory analytics on big data, with dynamic spillover to disk when data sets (also called data tables) get larger than available memory.</p>
<p>Traditional SAS reads data to and from disk row by row, which is potentially slow, but minimizes the amount of memory needed at any point in time which is why it scales well. (People comparing Viya to traditional SAS often refer to &#8220;SAS 9,&#8221; but SAS has always worked this way.)</p>
<p>Competing analytical tools are often designed to load entire data sets into memory all at once, which can be faster but will slow down and eventually fail as the size of a data set grows and exceeds the available memory.</p>
<p>CAS provides a “best of both worlds” approach, where large data sets can be loaded entirely into memory but will transition to disk-based processing automatically as needed.</p>
<p><span style="color: #800000"><strong>The many faces of SAS Viya</strong></span></p>
<p>The common element of all of the products included in Viya is that they all have the ability to use CAS as the underlying analytic engine. This includes point-and-click products such as SAS Visual Analytics and SAS Visual Statistics, but it also includes traditional SAS code running in CAS. In many cases the only change needed to make a SAS program take advantage of Viya is to point it at a CAS data set. Viya also includes R and Python packages which allow programmers to manipulate CAS data sets using those languages. Viya has its own environment for instructors and students called <a href="https://www.sas.com/en_us/software/viya-for-learners.html" rel="noopener" ref="nofollow" target="_blank">SAS Viya for Learners</a> which is separate from <a href="https://www.sas.com/en_us/software/on-demand-for-academics.html" rel="noopener" ref="nofollow" target="_blank">SAS OnDemand for Academics</a> which uses SAS 9.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://susanslaughter.wordpress.com/2023/01/10/what-is-sas-viya/"> Avocet Solutions</a> - go there to comment and to read  <a href="https://susanslaughter.wordpress.com/2023/01/10/what-is-sas-viya/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2023/01/what-is-sas-viya/">What is SAS Viya?</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://1.gravatar.com/avatar/ab3929e297fd5e64af04b42246ec59d4?s=96&#038;d=identicon&#038;r=G" length="0" type="" />

			</item>
		<item>
		<title>Understanding the _TYPE_ variable in output data sets</title>
		<link>http://proc-x.com/2023/01/understanding-the-_type_-variable-in-output-data-sets/</link>
		
		<dc:creator><![CDATA[Ron Cody]]></dc:creator>
		<pubDate>Tue, 10 Jan 2023 13:32:52 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[_TYPE_ variable]]></category>
		<category><![CDATA[class statement]]></category>
		<category><![CDATA[MEANS procedure]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[SUMMARY procedure]]></category>
		<category><![CDATA[Tech]]></category>
		<guid isPermaLink="false">https://blogs.sas.com/content/sgf/?p=43213</guid>

					<description><![CDATA[<p>When you use PROC MEANS or PROC SUMMARY to create a summary data set and include a CLASS statement, SAS includes two variables, _FREQ_ and _TYPE_, in the output data set. This blog shows you two ways to interpret and use _TYPE_ using the data set Shoes in the SASHELP [...]</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/10/understanding-the-_type_-variable-in-output-data-sets/">Understanding the _TYPE_ variable in output data sets</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf">SAS Users</a>.</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2023/01/understanding-the-_type_-variable-in-output-data-sets/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2023/01/understanding-the-_type_-variable-in-output-data-sets/">Understanding the _TYPE_ variable in output data sets</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/10/understanding-the-_type_-variable-in-output-data-sets/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/10/understanding-the-_type_-variable-in-output-data-sets/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p>When you use PROC MEANS or PROC SUMMARY to create a summary data set and include a CLASS statement, SAS includes two variables, _FREQ_ and _TYPE_, in the output data set.</p>
<p>This blog shows you two ways to interpret and use _TYPE_ using the data set Shoes in the SASHELP library.</p>
<p>Here is a listing showing the first five observations in this data set:</p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type1.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-medium wp-image-43219 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type1-300x115.png?resize=300%2C115&#038;ssl=1" alt="" width="300" height="115" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type1-300x115.png?resize=300%2C115&#038;ssl=1 300w, https://blogs.sas.com/content/sgf/files/2022/11/Type1.png 461w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>Because there are many regions and products, we are going to include a filter (WHERE statement) to restrict the number of Regions and Products. The first program looks at the sum of Sales for each Region.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">title</span> <span style="color: #a020f0;">&quot;Using a Single CLASS Variable&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc means</span> <span style="color: #000080; font-weight: bold;">data</span>=Sashelp.Shoes noprint;
   <span style="color: #0000ff;">where</span> Region <span style="color: #0000ff;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'Asia'</span>,<span style="color: #a020f0;">'United States'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">and</span>
         Product <span style="color: #0000ff;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'Boot'</span>,<span style="color: #a020f0;">'Sport Shoe'</span>,<span style="color: #a020f0;">'Sandle'</span><span style="color: #66cc66;">&#41;</span>;
   class Region;
   <span style="color: #0000ff;">var</span> Sales;
   <span style="color: #0000ff;">output</span> out=Summary_Region <span style="color: #0000ff;">n</span>= <span style="color: #0000ff;">sum</span>= / autoname;
<span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<p>The option NOPRINT suppresses the printed output (remember we are creating a summary data set).  The WHERE statement is selecting two Regions and three Products. The AUTONAME option in the OUTPUT statement automatically names the variables in the output data set. It uses the variable name(s) in the VAR statement, adds an underscore, followed by the name of the statistic. Here is the output:</p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type2.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-medium wp-image-43222 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type2-300x112.png?resize=300%2C112&#038;ssl=1" alt="" width="300" height="112" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type2-300x112.png?resize=300%2C112&#038;ssl=1 300w, https://blogs.sas.com/content/sgf/files/2022/11/Type2.png 349w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>The variable named Sales_Sum is the sum of the variable Sales and is given this name because of the AUTONAME option mentioned above. The first observation in the output data set shows the sum of sales for all Regions and the value of _TYPE_ is 0. The second and third observations are the sum of Sales for each Region and _TYPE_ has a value of 1. We will get into a detailed discussion of the _TYPE_ variable in the next example where we use two CLASS variables.</p>
<p>This next example uses two CLASS variables—Region and Product.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">title</span> <span style="color: #a020f0;">&quot;Using Two CLASS Variables&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc means</span> <span style="color: #000080; font-weight: bold;">data</span>=Sashelp.Shoes noprint;
   <span style="color: #0000ff;">where</span> Region <span style="color: #0000ff;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'Asia'</span>,<span style="color: #a020f0;">'United States'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">and</span>
         Product <span style="color: #0000ff;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'Boot'</span>,<span style="color: #a020f0;">'Sport Shoe'</span>,<span style="color: #a020f0;">'Sandle'</span><span style="color: #66cc66;">&#41;</span>;
   class Region Product;
   <span style="color: #0000ff;">var</span> Sales;
   <span style="color: #0000ff;">output</span> out=Summary_Region_Product <span style="color: #0000ff;">n</span>= <span style="color: #0000ff;">sum</span>= / autoname;
<span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<p>The listing is shown below:</p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type3.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-medium wp-image-43225 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type3-300x185.png?resize=300%2C185&#038;ssl=1" alt="" width="300" height="185" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type3-300x185.png?resize=300%2C185&#038;ssl=1 300w, https://blogs.sas.com/content/sgf/files/2022/11/Type3.png 435w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>Notice that there are now four values for the variable _TYPE_. _Type_ 0 is the sum of Sales for all Regions and all Products; _TYPE_ 1 is the sum of sales for each Product; _TYPE_ 2 is the sum of sales for each Region; and finally, _TYPE_ 3 is the sum of sales for each Region and Product. There is a somewhat complicated way to know what each value of _TYPE_ describes. Rather than go through that explanation, we are going to add the option CHARTYPE to PROC MEANS, making the explanation much simpler. Now let’s run the program above, but add the PROC MEANS option CHARTYPE as shown below.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">title</span> <span style="color: #a020f0;">&quot;Using Two CLASS Variables&quot;</span>;
title2 <span style="color: #a020f0;">&quot;Adding the Option CHARTYPE&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc means</span> <span style="color: #000080; font-weight: bold;">data</span>=Sashelp.Shoes noprint chartype;
   <span style="color: #0000ff;">where</span> Region <span style="color: #0000ff;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'Asia'</span>,<span style="color: #a020f0;">'United States'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">and</span>
         Product <span style="color: #0000ff;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'Boot'</span>,<span style="color: #a020f0;">'Sport Shoe'</span>,<span style="color: #a020f0;">'Sandle'</span><span style="color: #66cc66;">&#41;</span>;
   class Region Product;
   <span style="color: #0000ff;">var</span> Sales;
   <span style="color: #0000ff;">output</span> out=Summary_Region_Product <span style="color: #0000ff;">n</span>= <span style="color: #0000ff;">sum</span>= / autoname;
<span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<p>Here is the output:</p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type4.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-medium wp-image-43228 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type4-300x196.png?resize=300%2C196&#038;ssl=1" alt="" width="300" height="196" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type4-300x196.png?resize=300%2C196&#038;ssl=1 300w, https://blogs.sas.com/content/sgf/files/2022/11/Type4-214x140.png 214w, https://blogs.sas.com/content/sgf/files/2022/11/Type4.png 415w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>_TYPE_ is now a <strong>character</strong> variable with a string of 0s and 1s replacing the values of 0 to 3 with their binary values. To determine what each value of _TYPE_ describes, list the two CLASS variables and below them, the value of CHARTYPE, like this:</p>
<table>
<tbody>
<tr>
<th>CLASS Variable</th>
<th>Region</th>
<th>Product</th>
<th>Description</th>
</tr>
<tr>
<td>_TYPE_</td>
<td>0</td>
<td>0</td>
<td>Sum for all Regions and Products</td>
</tr>
<tr>
<td></td>
<td>0</td>
<td>1</td>
<td>Sum for each Product</td>
</tr>
<tr>
<td></td>
<td>1</td>
<td>0</td>
<td>Sum for each Region</td>
</tr>
<tr>
<td></td>
<td>1</td>
<td>1</td>
<td>Sum for each Region and Product</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>A 1 under the CLASS variable indicates that the statistic (sums and N in this example) is being computed for each value of that CLASS variable. Thus, _TYPE_ equal to 01 is the sum for each Product; _TYPE_ 10 is the sum for each Region; and _TYPE_ 11 is the sum for each combination of Region and Product.</p>
<p>If you want only the statistics for every combination of the CLASS variables, add the PROC MEAN option NWAY. Here is the result of adding the PROC MEANS option NWAY:</p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type5.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-medium wp-image-43231 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type5-300x120.png?resize=300%2C120&#038;ssl=1" alt="" width="300" height="120" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type5-300x120.png?resize=300%2C120&#038;ssl=1 300w, https://blogs.sas.com/content/sgf/files/2022/11/Type5.png 389w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>Because you usually want the statistics broken down by each of the CLASS variables, in most cases you will want to include the NWAY option. I like to remember to write NOPRINT and NWAY together so that I don&#8217;t forget.</p>
<p>In this last program, I&#8217;m going to show you how to use the _TYPE_ variable to create a separate data set for each value of _TYPE_. First, you need to run PROC MEANS without the NWAY option and include the CHARTYPE option. You follow this with a DATA step that create four data sets, each one corresponding to a different value of _TYPE_. Here is the program:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">title</span> <span style="color: #a020f0;">&quot;Using Two CLASS Variables&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc means</span> <span style="color: #000080; font-weight: bold;">data</span>=Sashelp.Shoes noprint chartype;
   <span style="color: #0000ff;">where</span> Region <span style="color: #0000ff;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'Asia'</span>,<span style="color: #a020f0;">'United States'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">and</span>
         Product <span style="color: #0000ff;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'Boot'</span>,<span style="color: #a020f0;">'Sport Shoe'</span>,<span style="color: #a020f0;">'Sandle'</span><span style="color: #66cc66;">&#41;</span>;
   class Region Product;
   <span style="color: #0000ff;">var</span> Sales;
   <span style="color: #0000ff;">output</span> out=Summary <span style="color: #0000ff;">n</span>= <span style="color: #0000ff;">sum</span>= / autoname;
<span style="color: #000080; font-weight: bold;">run</span>;
&nbsp;
<span style="color: #006400; font-style: italic;">*Creating seperate data sets for each _TYPE_ value;</span>
<span style="color: #000080; font-weight: bold;">data</span> Grand<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">keep</span>=Sales_N Sales_Sum<span style="color: #66cc66;">&#41;</span> 
     By_Region<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">keep</span>=Sales_N Sales_Sum Region<span style="color: #66cc66;">&#41;</span>
     By_Product<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">keep</span>=Sales_N Sales_Sum Product<span style="color: #66cc66;">&#41;</span>
     Cell_Sums<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">keep</span>=Sales_N Sales_Sum Region Product<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #0000ff;">set</span> Summary;
   <span style="color: #0000ff;">if</span> _TYPE_ = <span style="color: #a020f0;">'00'</span> <span style="color: #0000ff;">then</span> <span style="color: #0000ff;">output</span> Grand;
   <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> _TYPE_ = <span style="color: #a020f0;">'10'</span> <span style="color: #0000ff;">then</span> <span style="color: #0000ff;">output</span> By_Region;
   <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> _TYPE_ = <span style="color: #a020f0;">'01'</span> <span style="color: #0000ff;">then</span> <span style="color: #0000ff;">output</span> By_Product;
   <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> _TYPE_ = <span style="color: #a020f0;">'11'</span> <span style="color: #0000ff;">then</span> <span style="color: #0000ff;">output</span> Cell_Sums;
<span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<p>Use a KEEP= data set option to select which variables will be in each data set. For example, the value of Product will be a missing value for each observation in the By_Region data set. Also, the value of Region will be a missing value for each observation in the By_Product data set. The following figures show a listing of the four data sets:</p>
<p style="text-align: center"><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type6.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-full wp-image-43234 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type6.png?resize=182%2C91&#038;ssl=1" alt="" width="182" height="91" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type6.png?resize=182%2C91&#038;ssl=1 182w, https://blogs.sas.com/content/sgf/files/2022/11/Type6-164x82.png 164w" sizes="(max-width: 182px) 100vw, 182px" data-recalc-dims="1" /></a></p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type7.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-full wp-image-43237 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type7.png?resize=264%2C122&#038;ssl=1" alt="" width="264" height="122" data-recalc-dims="1" /></a></p>
<p style="text-align: center"><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type8.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-full wp-image-43240 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type8.png?resize=236%2C116&#038;ssl=1" alt="" width="236" height="116" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type8.png?resize=236%2C116&#038;ssl=1 236w, https://blogs.sas.com/content/sgf/files/2022/11/Type8-233x116.png 233w, https://blogs.sas.com/content/sgf/files/2022/11/Type8-164x82.png 164w" sizes="(max-width: 236px) 100vw, 236px" data-recalc-dims="1" /></a></p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type9.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="size-medium wp-image-43243 aligncenter" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type9-300x145.png?resize=300%2C145&#038;ssl=1" alt="" width="300" height="145" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/11/Type9-300x145.png?resize=300%2C145&#038;ssl=1 300w, https://blogs.sas.com/content/sgf/files/2022/11/Type9.png 311w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>Hopefully, this blog has given you the confidence to use and understand the _TYPE_ variable. If you want to learn more about programming in SAS, check out my book <a href="https://sasinstitute.redshelf.com/app/ecom/book/1878354/learning-sas-by-example-1878354-9781635266566-ron-cody" ref="nofollow" target="_blank">Learning SAS<sup>®</sup> by Example: A Programmer&#8217;s Guide, Second Edition</a>.</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/10/understanding-the-_type_-variable-in-output-data-sets/" ref="nofollow" target="_blank">Understanding the _TYPE_ variable in output data sets</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf" ref="nofollow" target="_blank">SAS Users</a>.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/10/understanding-the-_type_-variable-in-output-data-sets/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/10/understanding-the-_type_-variable-in-output-data-sets/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2023/01/understanding-the-_type_-variable-in-output-data-sets/">Understanding the _TYPE_ variable in output data sets</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://blogs.sas.com/content/sgf/files/2022/11/laura-chouette-6tdfx_gvHf0-unsplash-150x150.jpg" length="0" type="" />

			</item>
		<item>
		<title>New certification alert: SAS® Certified Specialist: Administration of SAS® Viya®</title>
		<link>http://proc-x.com/2023/01/new-certification-alert-sas-certified-specialist-administration-of-sas-viya/</link>
		
		<dc:creator><![CDATA[Kelly Hanson]]></dc:creator>
		<pubDate>Wed, 04 Jan 2023 14:46:07 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[SAS Administrators]]></category>
		<category><![CDATA[SAS Certification]]></category>
		<category><![CDATA[sas viya]]></category>
		<category><![CDATA[Tech]]></category>
		<guid isPermaLink="false">https://blogs.sas.com/content/sgf/?p=44007</guid>

					<description><![CDATA[<p>Thank you to my co-author Raymond Thomas for his assistance on this post. Learn more about the SAS Certified Specialist: Administration of SAS Viya and how to prepare. Certification overview SAS is pleased to announce a new SAS Viya Administration certification. Recognizing the growing need of cloud computing and Kubernetes, [...]</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/04/sas-certified-specialist-administration-of-sas-viya/">New certification alert: SAS® Certified Specialist: Administration of SAS® Viya®</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf">SAS Users</a>.</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2023/01/new-certification-alert-sas-certified-specialist-administration-of-sas-viya/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2023/01/new-certification-alert-sas-certified-specialist-administration-of-sas-viya/">New certification alert: SAS® Certified Specialist: Administration of SAS® Viya®</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/04/sas-certified-specialist-administration-of-sas-viya/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/04/sas-certified-specialist-administration-of-sas-viya/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p><em>Thank you to my co-author <a href="https://blogs.sas.com/content/author/raymondthomas/" ref="nofollow" target="_blank">Raymond Thomas</a> for his assistance on this post.</em></p>
<blockquote>
<p>Learn more about the SAS Certified Specialist: Administration of SAS Viya and how to prepare.</p>
</blockquote>
<h3>Certification overview</h3>
<p>SAS is pleased to announce a new SAS Viya Administration certification. Recognizing the growing need of cloud computing and Kubernetes, this new credential will help create a standard of knowledge within these areas.</p>
<p>Because of the growing skills required in cloud computing and Kubernetes, it’s critical that users can validate the skills they’ve learned and acquired to represent their knowledge. SAS developed the exam to cover the following major content areas:</p>
<ul>
• Manage a SAS Viya environment.<br />
• Monitor, log and troubleshoot a SAS Viya environment.<br />
• Manage identities and users.<br />
• Manage content and functionality.<br />
• Manage data in SAS Cloud Analytic Services (CAS).
</ul>
<p>View more details about the certification: <a href="https://www.sas.com/en_us/certification/credentials/administration/viya-admin-specialist.html" ref="nofollow" target="_blank">SAS Viya Administration Specialist | SAS</a>.</p>
<p>To see a full list of topics covered, select the “Exam Content Guide.”</p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/05/cert.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/05/cert.png?resize=350%2C235&#038;ssl=1" alt="" width="350" height="235" class="alignright size-full wp-image-39594" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/05/cert.png?resize=350%2C235&#038;ssl=1 350w, https://blogs.sas.com/content/sgf/files/2022/05/cert-300x201.png 300w" sizes="(max-width: 350px) 100vw, 350px" data-recalc-dims="1" /></a></p>
<h3>Why it&#8217;s so important</h3>
<p>This certification validates SAS Viya administration skills you have with employers. Proving your skillset through a certification shows your knowledge of managing and troubleshooting in SAS Viya, which greatly increases the opportunity for advancement in your career as a SAS administrator. Also, this certification is recognized worldwide by many leading industries, and obtaining this certification shows employers you are proactive and committed to your career.</p>
<h3>Related job roles &amp; industries</h3>
<p>SAS Viya Administration applies to job roles across many industries such as Pharmaceutical, Banking, and Government. A few examples of job roles that may benefit from using the SAS Viya Administration include System Architects, Cloud System Administrators, Systems Analyst, System Administrator, System Engineer, and Linux or Windows Administrators.</p>
<p>The certification is intended for anyone with direct responsibility in administering SAS Viya or anyone administering a SAS 9 environment migrating to SAS Viya. SAS Viya administrators support users across many industries and this skill is highly prevalent. </p>
<h3>How to prepare</h3>
<p>While there are no prerequisites to take this exam, students often use a combination of training and experience to study for this exam. To prepare for the exam, these resources are available:</p>
<p><strong>Courses</strong></p>
<ul>
• <a href="https://support.sas.com/edu/schedules.html?crs=SVFL&amp;ctry=US" ref="nofollow" target="_blank">SAS Training in the United States &#8212; SAS® Viya® Administration</a><br />
• <a href="https://support.sas.com/edu/schedules.html?crs=SVCL&amp;ctry=US" ref="nofollow" target="_blank">SAS Training in the United States &#8212; SAS® Viya® Operations</a>
</ul>
<p>There are two free e-learning courses that are no prerequisites that may also be beneficial during your exam preparation:</p>
<ul>
• <a href="https://support.sas.com/edu/schedules.html?crs=SPAGSV&amp;ctry=US" ref="nofollow" target="_blank">SAS Training in the United States &#8212; SAS® Viya® Administration: Getting Started</a><br />
• <a href="https://support.sas.com/edu/schedules.html?crs=SASKUB&amp;ctry=US" ref="nofollow" target="_blank">SAS Training in the United States &#8212; Getting Started with SAS® and Kubernetes</a><br />
• <a href="https://support.sas.com/edu/schedules.html?id=29049&amp;ctry=US" ref="nofollow" target="_blank">SAS Training in the United States &#8212; SAS® Viya® Administration Fast Track</a>
</ul>
<p><strong>Practice exam</strong></p>
<ul>
• <a href="https://www.sas.com/en_us/certification/training-exam-preparation.html" ref="nofollow" target="_blank">Exam Prep | SAS</a>
</ul>
<p><strong>Sample questions</strong></p>
<ul>
• <a href="https://www.sas.com/content/dam/SAS/documents/technical/certification/sample-test/viya-admin-sample-questions.pdf" ref="nofollow" target="_blank">SAS Viya Admin &#8211; Sample Questions</a>
</ul>
<h3>Registration details</h3>
<p>Follow this link to create an account or access your existing account to register: <a href="https://www.sas.com/en_us/certification/certification-manager.html" ref="nofollow" target="_blank">Certification Manager</a>.</p>
<p>For detailed exam topics, hit the &#8220;Exam Content Guide&#8221; links on each credential&#8217;s web page. The content guides contain exam sections, objectives, and expanded detail about the important topics.</p>
<p>The Specialist exam is A00-451. There are no pre-requisites for this exam, so anyone who is interested in this credential can register.</p>
<h3>Summary</h3>
<p>You can learn more about these new credentials at the links above. There you will find detailed exam content guides, free sample questions, and free practice exams (yes &#8211; free full length practice exams!).</p>
<p>We hope you tackle the recommended training, develop your skills, and register soon to be the first candidates to earn these credentials. Good luck with your preparations!</p>
<p>If you have additional questions, please ask in the comments below.</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2023/01/04/sas-certified-specialist-administration-of-sas-viya/" ref="nofollow" target="_blank">New certification alert: SAS® Certified Specialist: Administration of SAS® Viya®</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf" ref="nofollow" target="_blank">SAS Users</a>.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2023/01/04/sas-certified-specialist-administration-of-sas-viya/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2023/01/04/sas-certified-specialist-administration-of-sas-viya/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2023/01/new-certification-alert-sas-certified-specialist-administration-of-sas-viya/">New certification alert: SAS® Certified Specialist: Administration of SAS® Viya®</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://blogs.sas.com/content/sgf/files/2022/05/cert-150x150.png" length="0" type="" />

			</item>
		<item>
		<title>SAS training: 5 free sessions technologists love</title>
		<link>http://proc-x.com/2022/12/sas-training-5-free-sessions-technologists-love/</link>
		
		<dc:creator><![CDATA[Lexi Regalado]]></dc:creator>
		<pubDate>Fri, 23 Dec 2022 13:00:05 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[free training]]></category>
		<category><![CDATA[SAS Explore]]></category>
		<category><![CDATA[sas training]]></category>
		<category><![CDATA[sas viya]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Training]]></category>
		<guid isPermaLink="false">https://blogs.sas.com/content/sgf/?p=43726</guid>

					<description><![CDATA[<p>SAS Explore was created by technologists for technologists, and has more than 100 free SAS training sessions. Here are a few top picks!</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2022/12/23/sas-training-5-free-sessions-technologists-love/">SAS training: 5 free sessions technologists love</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf">SAS Users</a>.</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2022/12/sas-training-5-free-sessions-technologists-love/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2022/12/sas-training-5-free-sessions-technologists-love/">SAS training: 5 free sessions technologists love</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2022/12/23/sas-training-5-free-sessions-technologists-love/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2022/12/23/sas-training-5-free-sessions-technologists-love/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p>Data scientists are in short supply. McKinsey found the U.S. labor market alone is short 190,000 data scientists, and demand is growing. According to the World Data Science Initiative, &#8220;the data science market size is expected to grow from USD 95.3.9 billion in 2021 to USD 322.9 billion by 2026.” To help equip more data scientists to be ready for the world ahead, SAS created <a href="https://www.sas.com/en_us/events.html" ref="nofollow" target="_blank">SAS Explore</a>.</p>
<p>Created by technologists for technologists, SAS Explore has more than 100 free SAS training sessions. Data scientists, programmers, and analytics enthusiasts tuned in globally for our inaugural event.</p>
<p>Thanks to the high interest, these SAS training courses available to the public at no cost. Now, data scientists (and aspiring data scientists) can <a href="https://www.youtube.com/playlist?list=PLVBcK_IpFVi_cSE4l7ME3bb71ZW9Fe4RI" ref="nofollow" target="_blank">learn for free on demand</a>.</p>
<p>With so many sessions to choose from, it’s hard to choose only a few to highlight. In this article, you’ll find the top five technical sessions, according to audience rankings. Keep reading to get a peek at what you can learn with SAS Explore!</p>
<h2>#1: Creating Reports Again and Again&#8230; and Again with Macro</h2>
<p>You know you can create a flexible report with SAS using macro variables, but what about when it comes to multiple reports? What about sending the report to Microsoft Excel? This presentation focuses on using %if/%then logic and %do loops to enable you to create multiple excel reports. The macro definitions that create the reports are flexible, customizable, and, best of all, able to run repeatedly without needing to manually change anything!</p>
<p>In this session, you’ll learn how to create reports with Macro, how to define the ‘underperform’ value, exporting to excel, adding parameters, excel ODS options, and more.</p>
<h3>What attendees had to say about this session:</h3>
<ul>
<li><i>“Everything was helpful. Thank you so much!”</i></li>
<li><i>“Walking through all the code is something I value highly. There are many resources available online for SAS, but nothing beats someone explaining all the different code options.”</i></li>
<li><i>“In this session, I learned about non-positional in macros. Didn&#8217;t know that you could set defaults like that. I will be using that in my coding. Also, more in depth usage of %if %then %else macros that weren&#8217;t in the Coursera SAS training.”</i></li>
<li><i>“This is easily actionable content that will make a real difference to my coding efficiency.”</i></li>
</ul>
<p><b>Watch the full training session for free now on YouTube:</b></p>
<p><center><br />
<iframe loading="lazy" title="Creating Reports Again and Again.....and Again with Macro" width="702" height="395" src="https://www.youtube.com/embed/lxTKVvZdtTA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br />
</center></p>
<h2>#2: Using Python for Data Analytics in SAS® Viya®</h2>
<p>Unite the Python language with the analytic power of SAS. In this presentation, you’ll learn how to use the SWAT (SAS wrapper for analytics transfer) package to take advantage of the SAS Cloud Analytic Services (CAS) engine in SAS Viya for massively parallel processing (MPP).</p>
<p>This training begins with a quick overview of SAS Viya and the CAS engine and then discusses how to leverage the strengths of the CAS engine and your local Python client, how to connect Python to CAS, and how to access and load data into CAS&#8217;s MPP environment.</p>
<p>Then, you’ll dive into exploring, preparing, and analyzing data using the CAS server, taking advantage of the CAS server&#8217;s distributed processing power using familiar pandas API and CAS actions from the SWAT package. Lastly, you’ll learn how to unite traditional python packages such as Pandas and matplotlib with the summarized results from the CAS server for additional processing and visualization.</p>
<h3>What attendees had to say about this session:</h3>
<ul>
<li><i>“Lots of valuable information on using python in SAS!”</i></li>
<li><i>“The jupyter notebook format really made it easy to follow the presentation.”</i></li>
<li><i>“Overall, this session was outstanding.”</i></li>
</ul>
<p><b>Watch the full training session for free now on YouTube:</b></p>
<p><center><br />
<iframe loading="lazy" title="Using Python for Data Analytics in SAS Viya" width="702" height="395" src="https://www.youtube.com/embed/skd9-it5NPU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br />
</center></p>
<h2>#3: Software Workshop: End-to-End Machine Learning in Model Studio</h2>
<p>Effective predictive modeling projects follow the SAS analytics life cycle, from data to discovery and then deployment. SAS Viya provides the capability to perform all these steps from one graphical user interface, making the transition between stages of the analytics life cycle seamless.</p>
<p>In this training, you&#8217;ll load data into memory, prepare input variables for modeling, and build complex analytics pipelines to demonstrate powerful machine learning models. Need to better understand your model? No problem. We’ll show you how to produce model interpretability plots. Need to integrate open-source models? No problem. We’ll show you how to do that and deploy any model with one click. Then the best-performing model is saved and packaged for deployment, and you can still retrain this model on new data – all from the same shared interface.</p>
<h3>What attendees had to say about this session:</h3>
<ul>
<li><i>“The best session of all. Well explained!”</i></li>
<li><i>“Having a virtual lab where I can follow the training step-by-step gave me a fantastic experience. The instructor is amazing. Thank you all!”</i></li>
<li><i>“I learned about options that I did not know existed.”</i></li>
<li><i>“Being walked through the entire process from end to end was amazing!”</i></li>
</ul>
<p><b>Watch the full training session for free now on YouTube:</b></p>
<p><center><br />
<iframe loading="lazy" title="Software Workshop: End-to-End Machine Learning in Model Studio" width="702" height="395" src="https://www.youtube.com/embed/2WVRn7orols?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br />
</center></p>
<h2>#4: Speaking to Microsoft Excel with PROC SQL in SAS® Viya®</h2>
<p>Microsoft Excel, SQL and SAS are all equally loved for their unique strengths. Excel has been a go-to for a long time. Database workers live in SQL. SAS Viya is a cloud-enabled, in-memory analytics engine that provides quick, accurate, and reliable analytical insights. What would it be like to stay in the comfort of SAS while beckoning Excel in to join data using PROC SQL?</p>
<p>If you have wondered how this is possible, this is the session for you. Watch this incredible trio in action. You will learn to bring in data from Excel to SAS Viya using SAS engines, join multiple Excel spreadsheets, summarize data within SAS Viya using PROC SQL, and send the results to Excel. And you do all these things within SAS. Charu will show you a great way to build a bridge between SAS coders and colleagues who never code. All levels welcome!</p>
<h3>What attendees are saying:</h3>
<ul>
<li><i>“The whole session is useful!”</i></li>
<li><i>“Charu, thank you! Your teaching skills are excellent. The presentation was exceptionally clear. You add detail just where it is needed. Very easily understood. The steps in code were very logical. I think this presentation is the best I viewed in SAS Explore!”</i></li>
<li><i>“I loved the combination of the presenter&#8217;s communication skills and the step-by-step examples! Great job!!!!!!!!!!!!!!!!!!!!!!!!”</i></li>
</ul>
<p><b>Watch the full training session for free now on YouTube:</b></p>
<p><center><br />
<iframe loading="lazy" title="Speaking to Microsoft Excel with PROC SQL in SAS Viya" width="702" height="395" src="https://www.youtube.com/embed/bdisBSwL14E?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br />
</center></p>
<h2>#5: Struggling with Syntax? SAS® Studio to the Rescue!</h2>
<p>One of the more frustrating elements of learning to code in SAS is mastering the syntax. In this hands-on SAS training, you’ll learn how to use SAS Studio tasks in SAS OnDemand for Academics to automatically generate code for a range of statistical analyses such as t-tests, analysis of variance, linear regression, and logistic regression. For even more flexibility in our modeling, you’ll also learn also the autocomplete and dynamic syntax tooltips in the programming editor of SAS Studio – which aids in the construction of more dynamic statistical models.</p>
<p>Both sets of SAS Studio tools will help you obtain results from statistical analyses faster – so that you can focus more on the results… rather than the syntax errors. For our academic partners, this means more time covering course content – which makes you, and your students, more productive.</p>
<h3>What attendees are saying:</h3>
<ul>
<li><i>“This was a great session. Simple data but the analysis was laid out in a logical way and then shown how easy it was to code using pre-built tasks. The instructor was also very knowledgeable.”</i></li>
<li><i>“Concise and interesting demonstration. I liked that she used the same data set in all analyses.”</i></li>
<li><i>“I have never used the left menu before. Helpful to know a different way to do things.”</i></li>
</ul>
<p><b>Watch the full training session for free now on YouTube:</b></p>
<p><center><br />
<iframe loading="lazy" title="Struggling with Syntax? SAS Studio to the Rescue!" width="702" height="395" src="https://www.youtube.com/embed/JJLebTNtDF4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br />
</center></p>
<h2>Keep exploring free SAS training</h2>
<p>If you loved these free SAS trainings, you’ll love the rest too. Explore <a href="https://www.youtube.com/playlist?list=PLVBcK_IpFVi_cSE4l7ME3bb71ZW9Fe4RI" ref="nofollow" target="_blank">50+ free virtual sessions on our YouTube channel</a> now.</p>
<p>You’ll find topics like: <a href="https://www.youtube.com/watch?v=kHYaj5qiPow&amp;list=PLVBcK_IpFVi_cSE4l7ME3bb71ZW9Fe4RI&amp;index=4" ref="nofollow" target="_blank">SAS Viya in Microsoft Azure</a>, <a href="https://www.youtube.com/watch?v=L-b-V_nLNNE&amp;list=PLVBcK_IpFVi_cSE4l7ME3bb71ZW9Fe4RI&amp;index=22" ref="nofollow" target="_blank">Connected Supply Chain Planning</a>, <a href="https://youtu.be/0fnX5I5FTds" ref="nofollow" target="_blank">Building Analytical Applications</a>, <a href="https://youtu.be/4RoGXXLOx4Q" ref="nofollow" target="_blank">Demystifying SAS Certification</a>, <a href="https://youtu.be/r84p_EzPOpo" ref="nofollow" target="_blank">Automated Large-Scale Forecasting</a>, <a href="https://www.youtube.com/watch?v=ZPG9Dnjs5O8&amp;list=PLVBcK_IpFVi_cSE4l7ME3bb71ZW9Fe4RI&amp;index=5" ref="nofollow" target="_blank">Preventing Bias in AI</a>, and so much more.</p>
<p>All the sessions are full of tips and tricks to help you do more with SAS. Now that you’ve gotten a peek into the goodness that awaits, it’s time to <a href="https://www.youtube.com/playlist?list=PLVBcK_IpFVi_cSE4l7ME3bb71ZW9Fe4RI" ref="nofollow" target="_blank">dive into SAS Explore 2022 on demand!</a></p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2022/12/23/sas-training-5-free-sessions-technologists-love/" ref="nofollow" target="_blank">SAS training: 5 free sessions technologists love</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf" ref="nofollow" target="_blank">SAS Users</a>.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2022/12/23/sas-training-5-free-sessions-technologists-love/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2022/12/23/sas-training-5-free-sessions-technologists-love/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2022/12/sas-training-5-free-sessions-technologists-love/">SAS training: 5 free sessions technologists love</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://blogs.sas.com/content/sgf/files/2022/12/1146500506-150x150.jpg" length="0" type="" />

			</item>
		<item>
		<title>Creating a Microsoft Excel report using SAS, Python and SQL!</title>
		<link>http://proc-x.com/2022/12/creating-a-microsoft-excel-report-using-sas-python-and-sql/</link>
		
		<dc:creator><![CDATA[Peter Styliadis]]></dc:creator>
		<pubDate>Thu, 22 Dec 2022 14:31:29 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[ODS EXCEL]]></category>
		<category><![CDATA[ODS Excel destination]]></category>
		<category><![CDATA[PROC Python]]></category>
		<category><![CDATA[Programming Tips]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Python Integration to SAS Viya]]></category>
		<category><![CDATA[Python Procedure]]></category>
		<category><![CDATA[SAS programmers]]></category>
		<category><![CDATA[sas programming]]></category>
		<category><![CDATA[sas viya]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[tips & techniques]]></category>
		<guid isPermaLink="false">https://blogs.sas.com/content/sgf/?p=43327</guid>

					<description><![CDATA[<p>The addition of the PYTHON procedure and Python editor in SAS Viya enables users to execute Python code in SAS Studio. This new capability in SAS Viya adds another tool to SAS's existing collection. With this addition I thought, how can I utilize this new found power? In this example, [...]</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2022/12/22/creating-a-microsoft-excel-report-using-sas-python-and-sql/">Creating a Microsoft Excel report using SAS, Python and SQL!</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf">SAS Users</a>.</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2022/12/creating-a-microsoft-excel-report-using-sas-python-and-sql/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2022/12/creating-a-microsoft-excel-report-using-sas-python-and-sql/">Creating a Microsoft Excel report using SAS, Python and SQL!</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2022/12/22/creating-a-microsoft-excel-report-using-sas-python-and-sql/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2022/12/22/creating-a-microsoft-excel-report-using-sas-python-and-sql/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p>The addition of the <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/proc/n0asd2rsj9aedgn1828aptww56of.htm" ref="nofollow" target="_blank">PYTHON procedure</a> and <a href="https://go.documentation.sas.com/doc/en/webeditorcdc/v_011LTS/webeditorug/p07fdumu0y6e6on18jz1n7bsq68q.htm" ref="nofollow" target="_blank">Python editor</a> in SAS Viya enables users to execute Python code in SAS Studio. This new capability in SAS Viya adds another tool to SAS&#8217;s existing collection. With this addition I thought, how can I utilize this new found power?</p>
<p>In this example, I&#8217;ll keep it simple. I want to create a Microsoft Excel report using a combination of SAS, Python and SQL. I&#8217;ll use data that&#8217;s stored in a SAS library; however, the library could be using data stored anywhere, like a path, database or in the cloud. I&#8217;ll write a program that executes the following:</p>
<ul>
<li>the SAS <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/odsug/p09n5pw9ol0897n1qe04zeur27rv.htm" rel="noopener" ref="nofollow" target="_blank">ODS EXCEL statement</a> to create and Excel workbook</li>
<li>the <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/proc/p1dlh3svb4rrasn14h8jm6nyrj5o.htm" rel="noopener" ref="nofollow" target="_blank">PRINT procedure</a> and to print the detailed data</li>
<li>the <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/proc/n0asd2rsj9aedgn1828aptww56of.htm" rel="noopener" ref="nofollow" target="_blank">PYTHON procedure</a> to create violin plots using the matplotlib package</li>
<li>the <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0w2pkrm208upln11i9r4ogwyvow.htm" ref="nofollow" target="_blank">SQL procedure</a> for a simple aggregation</li>
<li>the <a href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/odsproc/p1tfjsx3ezqhacn1gqqsxqii7lpv.htm" rel="noopener" ref="nofollow" target="_blank">ODSTEXT procedure</a> to write a text in Excel</li>
</ul>
<p>All code used in this post is located on GitHub, <a href="https://github.com/sascommunities/sas-users-blog/tree/master/create-excel-report-using-sas-python-sql" ref="nofollow" target="_blank">here</a>.</p>
<h2>Set folder path and file name</h2>
<p>To begin, I&#8217;ll create a macro variable to specify the output folder path and Microsoft Excel workbook name.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">%let</span> path=<span style="color: #006400; font-style: italic;">/*Enter your output folder path*/</span>;
<span style="color: #0000ff;">%let</span> xlFileName = myExcelReport.xlsx;</pre>
</td>
</tr>
</table>
</div>
<h2>Prepare data</h2>
<p>Further, I&#8217;ll prepare the data using the SAS DATA step. I&#8217;ll use the available <strong>sashelp.cars</strong> table, create a new column named <strong>MPG_Avg</strong>, and drop unnecessary columns. Instead of using the DATA step you can use Python or SQL to prepare the data. Whatever tool works best for you.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">data</span> work.cars;
    <span style="color: #0000ff;">set</span> sashelp.cars;
    MPG_Avg=<span style="color: #0000ff;">mean</span><span style="color: #66cc66;">&#40;</span>MPG_City, MPG_Highway<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">drop</span> Wheelbase Weight <span style="color: #0000ff;">Length</span>;
<span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<h2>Create the Microsoft Excel workbook</h2>
<p>After the data is ready, I&#8217;ll use the ODS EXCEL statement to create the Excel spreadsheet. The following ODS options are used:</p>
<ul>
<li>FILE &#8211; specifies the file path and name.</li>
<li>STYLE &#8211; modifies the appearance of the SAS output</li>
<li>EMBEDDED_TITLES &#8211; specifies titles should appear in the worksheet</li>
<li>SHEET_INTERVAL &#8211; enables manual control when to create a new worksheet</li>
</ul>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;">ods excel <span style="color: #0000ff;">file</span>=<span style="color: #a020f0;">&quot;&amp;path./&amp;xlFileName&quot;</span> 
		  style=ExcelMidnight   
		  <span style="color: #0000ff;">options</span><span style="color: #66cc66;">&#40;</span>embedded_titles=<span style="color: #a020f0;">&quot;on&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre>
</td>
</tr>
</table>
</div>
<h3>Worksheet 1</h3>
<h4>Print the data using SAS</h4>
<p>With the ODS EXCEL destination open I&#8217;ll name the first worksheet <em>Data</em>, and manually specify when a new sheet is created. Next, I&#8217;ll use the PRINT procedure to print the detailed data to Excel. The PRINT procedure will print the entire SAS data set with the associated formats and styles to Excel.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #006400; font-style: italic;">* Sheet 1 - Print the data using SAS *;</span>
ods excel <span style="color: #0000ff;">options</span><span style="color: #66cc66;">&#40;</span>sheet_name=<span style="color: #a020f0;">'Data'</span> sheet_interval=<span style="color: #a020f0;">'none'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">title</span> height=16pt color=white <span style="color: #a020f0;">&quot;Detailed Car Data&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc print</span> <span style="color: #000080; font-weight: bold;">data</span>=work.cars noobs;
<span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<h3>Worksheet 2</h3>
<h4>Create violin plots using Python</h4>
<p>Next, I want to create violin plots on a new worksheet named <em>Origin_MPG</em>. Now, these can be created in <a href="https://blogs.sas.com/content/graphicallyspeaking/2012/10/30/violin-plots/" rel="noopener" ref="nofollow" target="_blank">SAS</a>, but I personally found the matplotlib package in Python a bit easier to use . With the PYTHON procedure, I can include the Python code within the SAS program (or you can reference a .py file) to create the visualization. Then I&#8217;ll use the SAS.pyplot method to save and render the visualization. Since the pyplot callback renders the image in the results tab, it exports the image to the Excel workbook by default.</p>
<p>First I&#8217;ll use ODS EXCEL to create the new worksheet and the TITLE statement to add a title to the Excel worksheet.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;">ods excel <span style="color: #0000ff;">options</span><span style="color: #66cc66;">&#40;</span>sheet_name=<span style="color: #a020f0;">'Origin_MPG'</span> sheet_interval=<span style="color: #a020f0;">'now'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">title</span> justify=<span style="color: #0000ff;">left</span> height=16pt color=white <span style="color: #a020f0;">&quot;Analyzing MPG by Each Car Origin&quot;</span>;</pre>
</td>
</tr>
</table>
</div>
<p>Then I&#8217;ll execute the PYTHON procedure to execute my Python code to create the violin plot.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="python" style="font-family:monospace;">* Create violin plots using Python *<span style="color: #66cc66;">;</span>
proc python<span style="color: #66cc66;">;</span>
submit<span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">##</span>
<span style="color: #808080; font-style: italic;">## Import packages and options</span>
<span style="color: #808080; font-style: italic;">##</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> pandas <span style="color: #ff7700;font-weight:bold;">as</span> pd
<span style="color: #ff7700;font-weight:bold;">import</span> matplotlib.<span style="color: black;">pyplot</span> <span style="color: #ff7700;font-weight:bold;">as</span> plt
plt.<span style="color: black;">style</span>.<span style="color: black;">use</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'fivethirtyeight'</span><span style="color: black;">&#41;</span>
outpath <span style="color: #66cc66;">=</span> SAS.<span style="color: black;">symget</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'path'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">##</span>
<span style="color: #808080; font-style: italic;">## Data prep for the visualization</span>
<span style="color: #808080; font-style: italic;">##</span>
&nbsp;
<span style="color: #808080; font-style: italic;">## Load the SAS table as a DataFrame</span>
df <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span>SAS
      .<span style="color: black;">sd2df</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'work.cars'</span><span style="color: black;">&#41;</span>                 <span style="color: #808080; font-style: italic;">## SAS callback method to load the SAS data set as a DataFrame</span>
      .<span style="color: black;">loc</span><span style="color: black;">&#91;</span>:<span style="color: #66cc66;">,</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'Origin'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'MPG_Avg'</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>        <span style="color: #808080; font-style: italic;">## Keep the necessary columns</span>
<span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">## Create a series of MPG_Avg for each distinct origin for the violin plots</span>
listOfUniqueOrigins <span style="color: #66cc66;">=</span> df.<span style="color: black;">Origin</span>.<span style="color: black;">unique</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">tolist</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
mpg_by_origin <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> origin <span style="color: #ff7700;font-weight:bold;">in</span> listOfUniqueOrigins:
    mpg_by_origin<span style="color: black;">&#91;</span>origin<span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> df.<span style="color: black;">query</span><span style="color: black;">&#40;</span>f<span style="color: #483d8b;">'Origin == @origin '</span><span style="color: black;">&#41;</span>.<span style="color: black;">MPG_Avg</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">##</span>
<span style="color: #808080; font-style: italic;">## Create the violin plots</span>
<span style="color: #808080; font-style: italic;">##</span>
&nbsp;
<span style="color: #808080; font-style: italic;">## Violin plot</span>
fig<span style="color: #66cc66;">,</span> ax <span style="color: #66cc66;">=</span> plt.<span style="color: black;">subplots</span><span style="color: black;">&#40;</span>figsize <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span><span style="color: #ff4500;">8</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">6</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
ax.<span style="color: black;">violinplot</span><span style="color: black;">&#40;</span>mpg_by_origin.<span style="color: black;">values</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> showmedians<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">## Plot appearance</span>
ax.<span style="color: black;">set_title</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Miles per Gallon (MPG) by Origin'</span><span style="color: black;">&#41;</span>
rename_x_axis <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">'position'</span>: <span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">2</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'labels'</span>:listOfUniqueOrigins<span style="color: black;">&#125;</span>
ax.<span style="color: black;">set_xticks</span><span style="color: black;">&#40;</span>rename_x_axis<span style="color: black;">&#91;</span><span style="color: #483d8b;">'position'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
ax.<span style="color: black;">set_xticklabels</span><span style="color: black;">&#40;</span>rename_x_axis<span style="color: black;">&#91;</span><span style="color: #483d8b;">'labels'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">## Save and render the image file</span>
SAS.<span style="color: black;">pyplot</span><span style="color: black;">&#40;</span>plt<span style="color: #66cc66;">,</span> filename<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'violinPlot'</span><span style="color: #66cc66;">,</span>filepath<span style="color: #66cc66;">=</span>outpath<span style="color: black;">&#41;</span>
&nbsp;
endsubmit<span style="color: #66cc66;">;</span>
quit<span style="color: #66cc66;">;</span>
title<span style="color: #66cc66;">;</span></pre>
</td>
</tr>
</table>
</div>
<h4>SQL Aggregation</h4>
<p>SQL is an extremely common and useful language for data analysts and scientists. I find using SQL for aggregation easy, so I will create a simple aggregation and add it below the visualization on the same worksheet in the the Excel report.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #006400; font-style: italic;">* SQL Aggregation *;</span>
<span style="color: #0000ff;">title</span> justify=<span style="color: #0000ff;">left</span> <span style="color: #a020f0;">&quot;Average MPG by Car Makes&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc sql</span>;
<span style="color: #0000ff;">select</span> Origin, <span style="color: #0000ff;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">mean</span><span style="color: #66cc66;">&#40;</span>MPG_Avg<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">as</span> AverageMPG
	<span style="color: #0000ff;">from</span> work.cars
	<span style="color: #0000ff;">group</span> <span style="color: #0000ff;">by</span> Origin
	<span style="color: #0000ff;">order</span> <span style="color: #0000ff;">by</span> AverageMPG desc;
<span style="color: #000080; font-weight: bold;">quit</span>;
<span style="color: #0000ff;">title</span>;</pre>
</td>
</tr>
</table>
</div>
<h4>Add text</h4>
<p>At the end of the same worksheet I&#8217;ll add some simple text using the ODSTEXT procedure to give some information about the data.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">proc odstext</span>;
   heading <span style="color: #a020f0;">'NOTES'</span>;
   p <span style="color: #a020f0;">'Using the SASHELP.CARS data. The following car Origins were analyzed:'</span>;
   <span style="color: #0000ff;">list</span> ;
      item <span style="color: #a020f0;">'Asia'</span>;
      item <span style="color: #a020f0;">'Europe'</span>;
      item <span style="color: #a020f0;">'USA'</span>;
   <span style="color: #0000ff;">end</span>;    
   p <span style="color: #a020f0;">'Created by Peter S'</span>;
<span style="color: #000080; font-weight: bold;">quit</span>;</pre>
</td>
</tr>
</table>
</div>
<h1>Close the Excel workbook</h1>
<p>Lastly, I&#8217;ll close the ODS EXCEL destination since I am done writing out to Excel.</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;">ods excel <span style="color: #0000ff;">close</span>;</pre>
</td>
</tr>
</table>
</div>
<h2>Results</h2>
<p>That&#8217;s it! Now I&#8217;ll execute the entire program and view the Excel workbook.</p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/PRINTRresults.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone size-full wp-image-43456" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/PRINTRresults.png?resize=560%2C230&#038;ssl=1" alt="" width="560" height="230" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/PRINTRresults.png?resize=560%2C230&#038;ssl=1 866w, https://blogs.sas.com/content/sgf/files/2022/12/PRINTRresults-300x123.png 300w, https://blogs.sas.com/content/sgf/files/2022/12/PRINTRresults-768x315.png 768w" sizes="(max-width: 866px) 100vw, 866px" data-recalc-dims="1" /></a></p>
<p><a href="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/Sheet2.png?ssl=1" ref="nofollow" target="_blank"><img loading="lazy" class="alignnone size-full wp-image-43459" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/Sheet2.png?resize=435%2C720&#038;ssl=1" alt="" width="435" height="720" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/Sheet2.png?resize=435%2C720&#038;ssl=1 435w, https://blogs.sas.com/content/sgf/files/2022/12/Sheet2-181x300.png 181w" sizes="(max-width: 435px) 100vw, 435px" data-recalc-dims="1" /></a></p>
<h2>Summary</h2>
<p>With the capabilities of SAS and the new ability to execute Python code in SAS Studio, teams have a variety of tools in SAS Viya for their analytic needs.</p>
<h3>Additional resources</h3>
<p><a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/proc/p0sj9pq2ryjlphn1ceq7ntpc1ipp.htm?fromDefault=" rel="noopener" ref="nofollow" target="_blank">PYTHON Procedure documentation</a><br />
<a href="https://blogs.sas.com/content/subconsciousmusings/2021/11/08/sas-studio-python-editor/" rel="noopener" ref="nofollow" target="_blank">SAS opens its code editor interface to Python users</a><br />
<a href="https://communities.sas.com/t5/SAS-Communities-Library/Using-PROC-PYTHON-to-augment-your-SAS-programs/ta-p/812397" rel="noopener" ref="nofollow" target="_blank">Using PROC PYTHON to augment your SAS programs</a><br />
<a href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/odsug/p09n5pw9ol0897n1qe04zeur27rv.htm" rel="noopener" ref="nofollow" target="_blank">ODS Excel Statement</a></p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2022/12/22/creating-a-microsoft-excel-report-using-sas-python-and-sql/" ref="nofollow" target="_blank">Creating a Microsoft Excel report using SAS, Python and SQL!</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf" ref="nofollow" target="_blank">SAS Users</a>.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2022/12/22/creating-a-microsoft-excel-report-using-sas-python-and-sql/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2022/12/22/creating-a-microsoft-excel-report-using-sas-python-and-sql/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2022/12/creating-a-microsoft-excel-report-using-sas-python-and-sql/">Creating a Microsoft Excel report using SAS, Python and SQL!</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://blogs.sas.com/content/sgf/files/2022/12/SAS-Viya-CAS-Blogs-150x150.jpg" length="0" type="" />

			</item>
		<item>
		<title>Decode your SAS® macro code with the MFILE and MPRINT options</title>
		<link>http://proc-x.com/2022/12/decode-your-sas-macro-code-with-the-mfile-and-mprint-options/</link>
		
		<dc:creator><![CDATA[Bari Lawhorn]]></dc:creator>
		<pubDate>Wed, 21 Dec 2022 17:00:55 +0000</pubDate>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[Problem Solvers]]></category>
		<category><![CDATA[Tech]]></category>
		<guid isPermaLink="false">https://blogs.sas.com/content/sgf/?p=43699</guid>

					<description><![CDATA[<p>SAS' Bari Lawhorn introduces you to the MFILE option as a way to home in on errors and warnings in your macros.</p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2022/12/21/decode-your-sas-macro-code/">Decode your SAS® macro code with the MFILE and MPRINT options</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf">SAS Users</a>.</p>
<p class="more-link-p"><a class="more-link" href="http://proc-x.com/2022/12/decode-your-sas-macro-code-with-the-mfile-and-mprint-options/">Read more &#8594;</a></p>
<p>The post <a href="http://proc-x.com/2022/12/decode-your-sas-macro-code-with-the-mfile-and-mprint-options/">Decode your SAS® macro code with the MFILE and MPRINT options</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2022/12/21/decode-your-sas-macro-code/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2022/12/21/decode-your-sas-macro-code/">the full post. </a></strong>
</td>
</tr>
</table>
</p>
<p><img loading="lazy" class="alignright size-medium wp-image-37964" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/02/ProblemSolvers-300x300.jpg?resize=300%2C300&#038;ssl=1" alt="" width="300" height="300" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/02/ProblemSolvers-300x300.jpg?resize=300%2C300&#038;ssl=1 300w, https://blogs.sas.com/content/sgf/files/2022/02/ProblemSolvers-150x150.jpg 150w, https://blogs.sas.com/content/sgf/files/2022/02/ProblemSolvers.jpg 400w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" />How often have you wanted a secret decoder ring to view the resolved values of your macro variables or to isolate an error or warning that is occurring in your SAS macro code logic? Well, the MFILE option can be that decoder!</p>
<p>When you use the MFILE and MPRINT options and use a FILENAME statement with the MPRINT fileref, SAS routes the code that is generated and submitted by your macro to a text file the next time that you call your macro. You can then examine and run all or part of the code in the text file to help debug your program. This blog post provides three examples of how you can use these options to improve your use of macro code.</p>
<h2>Example 1: Understanding the macro code</h2>
<p>Here’s an example where I am using code that was written by another programmer. I want to understand what the macro variables inside the TEST macro resolve to and what SAS code the TEST macro creates:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"> <span style="color: #0000ff;">%macro</span> test<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span>;
&nbsp;
   ods rtf <span style="color: #0000ff;">file</span>=<span style="color: #a020f0;">&quot;&amp;value..rtf&quot;</span>;
     <span style="color: #000080; font-weight: bold;">proc print</span> <span style="color: #000080; font-weight: bold;">data</span>=one<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">where</span>=<span style="color: #66cc66;">&#40;</span>state=<span style="color: #a020f0;">&quot;&amp;value&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
     <span style="color: #000080; font-weight: bold;">run</span>;
   ods rtf <span style="color: #0000ff;">close</span>;
&nbsp;
   <span style="color: #0000ff;">%mend</span>;
&nbsp;
<span style="color: #000080; font-weight: bold;">data</span> one;
     <span style="color: #0000ff;">input</span> state $ age;
   datalines;
   VA <span style="color: #2e8b57; font-weight: bold;">21</span>
   VA <span style="color: #2e8b57; font-weight: bold;">23</span>
   MD <span style="color: #2e8b57; font-weight: bold;">23</span>
   MD <span style="color: #2e8b57; font-weight: bold;">12</span>
   MA <span style="color: #2e8b57; font-weight: bold;">12</span>
   MA <span style="color: #2e8b57; font-weight: bold;">34</span>
   ;
&nbsp;
   <span style="color: #000080; font-weight: bold;">proc sort</span> ;
     <span style="color: #0000ff;">by</span> state;
   <span style="color: #000080; font-weight: bold;">run</span>;
&nbsp;
  <span style="color: #000080; font-weight: bold;">data</span> <span style="color: #0000ff;">_null_</span>;
     <span style="color: #0000ff;">set</span> one;
     <span style="color: #0000ff;">by</span> state;
     <span style="color: #0000ff;">if</span> first.state <span style="color: #0000ff;">then</span>
       <span style="color: #0000ff;">call</span> execute<span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'%test('</span>||state||<span style="color: #a020f0;">')'</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<p>Here is how I call the TEST macro with the MFILE and MPRINT options in effect and a FILENAME statement that uses the MPRINT fileref:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;">   <span style="color: #0000ff;">options</span> mprint mfile;
   <span style="color: #0000ff;">filename</span> mprint <span style="color: #a020f0;">&quot;c:<span style="color: #000099; font-weight: bold;">\t</span>emp<span style="color: #000099; font-weight: bold;">\n</span>omacro.sas&quot;</span>;
&nbsp;
  <span style="color: #000080; font-weight: bold;">data</span> <span style="color: #0000ff;">_null_</span>;
     <span style="color: #0000ff;">set</span> one;
     <span style="color: #0000ff;">by</span> state;
     <span style="color: #0000ff;">if</span> first.state <span style="color: #0000ff;">then</span>
       <span style="color: #0000ff;">call</span> execute<span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'%test('</span>||state||<span style="color: #a020f0;">')'</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<p>This program results in the following code being sent to the nomacro.sas file:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;">ods rtf <span style="color: #0000ff;">file</span>=<span style="color: #a020f0;">&quot;MA.rtf&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc print</span> <span style="color: #000080; font-weight: bold;">data</span>=one<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">where</span>=<span style="color: #66cc66;">&#40;</span>state=<span style="color: #a020f0;">&quot;MA&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
ods rtf <span style="color: #0000ff;">close</span>;
ods rtf <span style="color: #0000ff;">file</span>=<span style="color: #a020f0;">&quot;MD.rtf&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc print</span> <span style="color: #000080; font-weight: bold;">data</span>=one<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">where</span>=<span style="color: #66cc66;">&#40;</span>state=<span style="color: #a020f0;">&quot;MD&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
ods rtf <span style="color: #0000ff;">close</span>;
ods rtf <span style="color: #0000ff;">file</span>=<span style="color: #a020f0;">&quot;VA.rtf&quot;</span>;
<span style="color: #000080; font-weight: bold;">proc print</span> <span style="color: #000080; font-weight: bold;">data</span>=one<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">where</span>=<span style="color: #66cc66;">&#40;</span>state=<span style="color: #a020f0;">&quot;VA&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
ods rtf <span style="color: #0000ff;">close</span>;</pre>
</td>
</tr>
</table>
</div>
<p>In the file, I see that all of the macro variables resolved to state abbreviations, and I can then choose to run all or part of the code as desired. That was easy!</p>
<h2>Example 2: Understanding exactly where an issue occurs in macro code</h2>
<p>In the following log file, I’m confused because the NOTE about an invalid argument to the INPUT function seems to occur on the line where I invoked my macro and I want more specific information:</p>
<p><img loading="lazy" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/Picture1.png?resize=560%2C151&#038;ssl=1" alt="" width="560" height="151" class="alignnone size-full wp-image-43717" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/Picture1.png?resize=560%2C151&#038;ssl=1 624w, https://blogs.sas.com/content/sgf/files/2022/12/Picture1-300x81.png 300w" sizes="(max-width: 624px) 100vw, 624px" data-recalc-dims="1" /></p>
<p>Kevin Russell explains why the NOTE occurs in this location in his <a href="https://support.sas.com/resources/papers/387699_macro-programming-tools.pdf" ref="nofollow" target="_blank">Surviving the SAS® Macro Jungle by Using Your Own Programming Toolkit</a> paper:</p>
<p><em>The line number in the NOTE points to the line where the macro is invoked instead of pointing to the line that contains the INPUT function. The NOTE points to this line because it is the invocation of the macro that generates the INPUT function code that then generates the NOTE. Because there is currently no option other than having the NOTE point to the line where the macro is invoked, you can use the MFILE system option to debug</em>.</p>
<p>I can use the MFILE option to discover where the problem with the INPUT function actually occurs:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">filename</span> mprint <span style="color: #a020f0;">&quot;c:<span style="color: #000099; font-weight: bold;">\t</span>emp<span style="color: #000099; font-weight: bold;">\n</span>omacro_note.sas&quot;</span>;
<span style="color: #0000ff;">options</span> mprint mfile;
%cars</pre>
</td>
</tr>
</table>
</div>
<p>The resulting submission of the code from the nomacro_note.sas file helps me find the problematic line, line 75. It is not hard to find the issue when you use the problematic function only one time; but in the real world, these functions are used OFTEN:</p>
<p><img loading="lazy" src="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/Picture2.png?resize=560%2C99&#038;ssl=1" alt="" width="560" height="99" class="alignnone size-full wp-image-43720" srcset="https://i0.wp.com/blogs.sas.com/content/sgf/files/2022/12/Picture2.png?resize=560%2C99&#038;ssl=1 624w, https://blogs.sas.com/content/sgf/files/2022/12/Picture2-300x53.png 300w" sizes="(max-width: 624px) 100vw, 624px" data-recalc-dims="1" /></p>
<h2>Example 3: Including dependent code for the macro</h2>
<p>What if I have some precode that is outside of the macro, or another macro that I need to use as part of my debugging? In this case, I am not sure that I will need a PROC PRINT step to debug my CARS macro, but I would like to ensure that it is included in my decoded file (using MFILE). So, I can use the MFILE option to include that code in a file that I can parse out later. Here&#8217;s the code that I want to run:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">%let</span> name1=Asia;
<span style="color: #0000ff;">%let</span> i=<span style="color: #2e8b57; font-weight: bold;">1</span>;
&nbsp;
<span style="color: #000080; font-weight: bold;">proc print</span> <span style="color: #000080; font-weight: bold;">data</span>=sashelp.cars; 
 <span style="color: #0000ff;">title</span> <span style="color: #a020f0;">&quot;&amp;&amp;name&amp;i&quot;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
&nbsp;
<span style="color: #0000ff;">%macro</span> cars;
<span style="color: #000080; font-weight: bold;">data</span> cars;
 <span style="color: #0000ff;">set</span> sashelp.cars;
 new=<span style="color: #0000ff;">input</span><span style="color: #66cc66;">&#40;</span>origin,<span style="color: #2e8b57; font-weight: bold;">1</span>.<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
<span style="color: #0000ff;">%mend</span>;</pre>
</td>
</tr>
</table>
</div>
<p>I wrap the code in the OUTER macro and then use MFILE and MPRINT to “decode”:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #0000ff;">%macro</span> outer;
<span style="color: #0000ff;">%let</span> name1=Asia;
<span style="color: #0000ff;">%let</span> i=<span style="color: #2e8b57; font-weight: bold;">1</span>;
&nbsp;
<span style="color: #000080; font-weight: bold;">proc print</span> <span style="color: #000080; font-weight: bold;">data</span>=sashelp.cars; 
 <span style="color: #0000ff;">title</span> <span style="color: #a020f0;">&quot;&amp;&amp;name&amp;i&quot;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
&nbsp;
<span style="color: #0000ff;">%macro</span> cars;
<span style="color: #000080; font-weight: bold;">data</span> cars;
<span style="color: #0000ff;">set</span> sashelp.cars;
new=<span style="color: #0000ff;">input</span><span style="color: #66cc66;">&#40;</span>origin,<span style="color: #2e8b57; font-weight: bold;">1</span>.<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
<span style="color: #0000ff;">%mend</span>;
&nbsp;
%cars
&nbsp;
<span style="color: #0000ff;">%mend</span> outer;
&nbsp;
<span style="color: #0000ff;">filename</span> mprint <span style="color: #a020f0;">&quot;c:<span style="color: #000099; font-weight: bold;">\t</span>emp<span style="color: #000099; font-weight: bold;">\o</span>uter.sas&quot;</span>;
<span style="color: #0000ff;">options</span> mprint mfile;
%outer</pre>
</td>
</tr>
</table>
</div>
<p>Here is the outer.sas file for later decoding:</p>
<div class="wp_syntax">
<table>
<tr>
<td class="code">
<pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">proc print</span> <span style="color: #000080; font-weight: bold;">data</span>=sashelp.cars;
<span style="color: #0000ff;">title</span> <span style="color: #a020f0;">&quot;Asia&quot;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;
<span style="color: #000080; font-weight: bold;">data</span> cars;
<span style="color: #0000ff;">set</span> sashelp.cars;
new=<span style="color: #0000ff;">input</span><span style="color: #66cc66;">&#40;</span>origin,<span style="color: #2e8b57; font-weight: bold;">1</span>.<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000080; font-weight: bold;">run</span>;</pre>
</td>
</tr>
</table>
</div>
<h2>Conclusion</h2>
<p>Paired with the MPRINT option, the MFILE option is especially helpful if you are seeing errors, warning messages, or code behavior that you cannot explain or diagnose easily from reading your SAS log. MFILE gives you clean code that you can submit, without having to copy the MPRINT output from the log window to another file and remove the (MPRINT) headers. It is a code strategy that might also prove useful if you need to involve SAS Technical Support, because it’s especially helpful for you to provide SAS Technical Support with the smallest subset of your code that demonstrates the problem that you are encountering.</p>
<p>Although these options are useful, note these restrictions:</p>
<ul>
<li>If you generate code with MFILE, it does not contain any formatting such as code indention.</li>
<li>If you generate code with MFILE, it does not contain PL1 style comments (/* comment here */).</li>
<li>If the macro is a stored compiled macro that was compiled with the NOMPRINT option in effect, then the MFILE and MPRINT options do not generate a file.</li>
</ul>
<p>Tell me how you have found this blog useful!</p>
<h1>References:</h1>
<p><a href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/mcrolref/p0j3zpinabl49ln13q5f5r1t46mg.htm" ref="nofollow" target="_blank">SAS Help Center: MFILE Macro System Option</a></p>
<p><a href="https://support.sas.com/kb/23/138.html" ref="nofollow" target="_blank">23138 &#8211; How can I remove macro code from my original program and create a file of the code that is generated by SAS so debugging the code is easier?</a></p>
<p><a href="https://support.sas.com/resources/papers/387699_macro-programming-tools.pdf" ref="nofollow" target="_blank">Surviving the SAS® Macro Jungle by Using Your Own Programming Toolkit</a></p>
<p><a rel="nofollow" href="https://blogs.sas.com/content/sgf/2022/12/21/decode-your-sas-macro-code/" ref="nofollow" target="_blank">Decode your SAS® macro code with the MFILE and MPRINT options</a> was published on <a rel="nofollow" href="https://blogs.sas.com/content/sgf" ref="nofollow" target="_blank">SAS Users</a>.</p>

<p class="syndicated-attribution"><table border="1">
<tr>
<td>
<strong>This post was kindly contributed by <a href="https://blogs.sas.com/content/sgf/2022/12/21/decode-your-sas-macro-code/"> SAS Users</a> - go there to comment and to read  <a href="https://blogs.sas.com/content/sgf/2022/12/21/decode-your-sas-macro-code/">the full post. </a></strong>
</td>
</tr>
</table>
</p><p>The post <a href="http://proc-x.com/2022/12/decode-your-sas-macro-code-with-the-mfile-and-mprint-options/">Decode your SAS® macro code with the MFILE and MPRINT options</a> first appeared on <a href="http://proc-x.com">PROC-X.com</a>.</p>]]></content:encoded>
					
		
		<enclosure url="https://blogs.sas.com/content/sgf/files/2022/02/ProblemSolvers-150x150.jpg" length="0" type="" />

			</item>
	</channel>
</rss>
