<?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/"
	>

<channel>
	<title>Statskom</title>
	<atom:link href="http://statskom.com/tag/proc-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://statskom.com</link>
	<description>Clinical programming</description>
	<lastBuildDate>Thu, 05 Oct 2017 09:04:02 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.8.41</generator>
	<item>
		<title>SAS tips &amp; tricks #11 &#8211; PROC SQL; INSERT INTO</title>
		<link>http://statskom.com/sas-tips-tricks-11-proc-sql-insert-into/</link>
		<comments>http://statskom.com/sas-tips-tricks-11-proc-sql-insert-into/#comments</comments>
		<pubDate>Thu, 06 Nov 2014 08:19:52 +0000</pubDate>
		<dc:creator><![CDATA[Andrew N]]></dc:creator>
				<category><![CDATA[SAS Tips & Tricks]]></category>
		<category><![CDATA[INSERT INTO]]></category>
		<category><![CDATA[PROC SQL]]></category>
		<category><![CDATA[sas tips and tricks]]></category>

		<guid isPermaLink="false">http://statskom.com/?p=465</guid>
		<description><![CDATA[<p>In this tips &#38; tricks post we look at how PROC SQL INSERT INTO provides a concise method for inserting additional rows into a dataset. Sometimes it is necessary to force additional observations into your datasets, inserting new observations into&#8230; </p><p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-11-proc-sql-insert-into/">SAS tips &#038; tricks #11 &#8211; PROC SQL; INSERT INTO</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In this tips &amp; tricks post we look at how PROC SQL INSERT INTO provides a concise method for inserting additional rows into a dataset.</p>
<p>Sometimes it is necessary to force additional observations into your datasets, inserting new observations into a dataset with the Data Step usually involves either creating ta new dataset containing the new observations using a  DATALINES statement and then appending this dataset with the original, or alternatively  using multiple OUTPUT statements  within a Data Step.</p>
<h3><strong> DATALINES method</strong></h3>
<pre>DATA class_in;
  ATTRIB name LENGTH = $8 sex LENGTH = $1;
  INFILE DATALINES;
  INPUT name sex age height weight;
  DATALINES;
Andy M 30 190 100
Ben M 60 180 110
Paul M 26 170 120
;
RUN;
PROC APPEND BASE = class DATA = class_in;
RUN;</pre>
<h3><strong>Multiple OUTPUT statement method</strong></h3>
<pre>DATA class;
  SET class;
  OUTPUT;
  name = "Andy";
  sex  = "M";
  age = 30;
  height = 190;
  weight = 100;
  OUTPUT; 
  name = "Ben";
  sex  = "M";
  age = 60;
  height = 180;
  weight = 110;
  OUTPUT; 
  name = "Paul";
  sex  = "M";
  age = 26 ;
  height = 170 ;
  weight = 120;
  OUTPUT; 
RUN;</pre>
<p>&nbsp;</p>
<h3><strong>PROC SQL INSERT INTO method</strong></h3>
<p>The DATALINES method is not ideal as it involves creating an additional dataset and ensuring that the variable lengths in the new dataset  are consistent with the length in the original dataset, otherwise truncation can occur. Whereas the Multiple OUTPUT statement method can be time consuming and error prone because it required one assignment statement to be manually typed out for each variable in each observation. The PROC SQL INSERT INTO approach provides a concise alternative to these methods. This approach inserts lines using the VALUES statement in combination with a comma separated list, as shown below:</p>
<pre>PROC SQL NOPRINT ; 
  INSERT INTO class
  VALUES ("Andy", "M", 30,190,100)
  VALUES ("Ben", "M", 60,180,110)
  VALUES ("PAUL", "M", 26,170,120); 
QUIT;</pre>
<p>If using this approach, care should be taken to ensure that the order of the values in the comma separated list is consistent with the order of the associated variable in the dataset. To minimise the possibility of making a mistake in the order, or if you want to populate certain columns only, the columns which you wish to update, and the order of the variables in your comma separated list can be specified in brackets after the name of the dataset, as shown below:</p>
<pre>PROC SQL; 
  INSERT INTO class (name,weight)
  VALUES ("Andy",100)
  VALUES ("Ben",110)
  VALUES ("PAUL",.); 
QUIT;</pre>
<p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-11-proc-sql-insert-into/">SAS tips &#038; tricks #11 &#8211; PROC SQL; INSERT INTO</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://statskom.com/sas-tips-tricks-11-proc-sql-insert-into/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SAS tips &amp; tricks #4 – Visualising SAS datasets with an sql histogram</title>
		<link>http://statskom.com/sas-tips-tricks-4-visualising-datasets-sql-histogram/</link>
		<comments>http://statskom.com/sas-tips-tricks-4-visualising-datasets-sql-histogram/#comments</comments>
		<pubDate>Thu, 28 Aug 2014 14:52:18 +0000</pubDate>
		<dc:creator><![CDATA[Andrew N]]></dc:creator>
				<category><![CDATA[SAS Tips & Tricks]]></category>
		<category><![CDATA[histogram]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[PROC SQL]]></category>
		<category><![CDATA[SAS]]></category>

		<guid isPermaLink="false">http://statskom.com/?p=276</guid>
		<description><![CDATA[<p>In our last post SAS tips &#38; tricks #3 – SAS dictionary tables, we looked at how the dictionary tables can be used to find metadata about the SAS session, including dataset and variable level metadata. In this post we&#8230; </p><p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-4-visualising-datasets-sql-histogram/">SAS tips &#038; tricks #4 – Visualising SAS datasets with an sql histogram</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In our last post <a title="SAS tips &amp; tricks #3 – SAS dictionary tables" href="http://statskom.com/sas-tips-tricks-3-sas-dictionary-tables/">SAS tips &amp; tricks #3 – SAS dictionary tables</a>, we looked at how the dictionary tables can be used to find metadata about the SAS session, including dataset and variable level metadata.</p>
<p>In this post we look at how we can use a simple piece of SQL to create a histogram which gives a quick overview of the number of variables in each domain.</p>
<p>The SASHELP.VCOLUMN dataset contains a list of all variables present in each dataset. Here we use the repeat function to output a &#8220;*&#8221; character for each variable in the dataset. The output of the query is printed to the active output destination.</p>
<pre>PROC SQL;
   SELECT memname  , REPEAT('*',nvar) AS freq
   FROM sashelp.vtable
   WHERE libname = "SASHELP";
 QUIT;</pre>
<p>The result is something similar to the below, which gives a quick insight into the number of variables in each dataset in the SASHELP library.</p>
<p><a href="http://statskom.com/wp-content/uploads/2014/08/sql_histogram_vars.jpg"><img class="alignnone size-full wp-image-284" alt="sql_histogram_vars" src="http://statskom.com/wp-content/uploads/2014/08/sql_histogram_vars.jpg" width="531" height="706" /></a></p>
<p>This SQL histogram technique has a wide varierty of other applications, for example here we use it to show the frequency of countries within each region in the SASHELP.DEMOGRAPHICS dataset.</p>
<p>&nbsp;</p>
<pre>PROC SQL;
  SELECT region , REPEAT('*',COUNT(*)) AS freq
  FROM sashelp.demographics
  GROUP BY region
  ORDER BY region;
QUIT;</pre>
<p><a href="http://statskom.com/wp-content/uploads/2014/08/sql_histogram_region.jpg"><img class="alignnone  wp-image-283" alt="sql_histogram_region" src="http://statskom.com/wp-content/uploads/2014/08/sql_histogram_region.jpg" width="673" height="117" /></a></p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-4-visualising-datasets-sql-histogram/">SAS tips &#038; tricks #4 – Visualising SAS datasets with an sql histogram</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://statskom.com/sas-tips-tricks-4-visualising-datasets-sql-histogram/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SAS paper review #3</title>
		<link>http://statskom.com/sas-paper-review-3/</link>
		<comments>http://statskom.com/sas-paper-review-3/#comments</comments>
		<pubDate>Mon, 03 Mar 2014 20:44:21 +0000</pubDate>
		<dc:creator><![CDATA[Andrew N]]></dc:creator>
				<category><![CDATA[SAS paper review]]></category>
		<category><![CDATA[FEEDBACK]]></category>
		<category><![CDATA[PROC SQL]]></category>
		<category><![CDATA[SAS]]></category>
		<category><![CDATA[SESUG]]></category>
		<category><![CDATA[VALIDATE]]></category>

		<guid isPermaLink="false">http://statskom.com/?p=250</guid>
		<description><![CDATA[<p>This week our SAS paper review looks at  “A Closer Look at PROC SQL’s FEEDBACK Option” by Kenneth W. Borowiak. The paper explores how the FEEDBACK option can be used in the SQL statement  to cause SAS to create additionally detailed&#8230; </p><p>The post <a rel="nofollow" href="http://statskom.com/sas-paper-review-3/">SAS paper review #3</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>This week our SAS paper review looks at  “A Closer Look at PROC SQL’s FEEDBACK Option” by <span style="color: #000000;"><span style="font-size: medium;">Kenneth W. Borowiak</span>.</span></p>
<p>The paper explores how the FEEDBACK option can be used in the SQL statement  to cause SAS to create additionally detailed log entries which can be useful for debugging. It explains  how use of the FEEDBACK option will cause SAS to write expanded, more explicit messages in the log, which for example explicitly list any variables that were implicitly selected with a SELECT * construction.</p>
<p>We particularly liked the Code Generation section in which Borowiak’s suggests using the FEEDBACK option in combination with the VALIDATE statement to write an expanded version of the SELECT * statement into the log, which can then be copied back into the program and executed.</p>
<p>We feel the paper is suitable for all SAS users who utilise, or are learning SQL.</p>
<p>The paper was presented at the SouthEast SAS® Users Group, 2012 Conference in Raleigh-Durham, North Carolina. Download the paper from the <a href="http://analytics.ncsu.edu/sesug/2012/CT-05.pdf">SESUG website.</a></p>
<p>The post <a rel="nofollow" href="http://statskom.com/sas-paper-review-3/">SAS paper review #3</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://statskom.com/sas-paper-review-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
