<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Separate Outputs not handling spaces(creates extra data set) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Separate-Outputs-not-handling-spaces-creates-extra-data-set/m-p/419303#M103085</link>
    <description>&lt;P&gt;You have two possibilities: Either you change the variable to a valid SAS version 7 (or earlier) name, or you use option VALIDVARNAME=ANY and use a quoted string for your data set name. The second solution may be easier, as you can use the same macro variable for the WHERE clause and the data set name:&lt;/P&gt;&lt;PRE&gt;data "&amp;amp;&amp;amp;subj&amp;amp;i"n;
  set have;
  where deptdescription="&amp;amp;&amp;amp;subj&amp;amp;i";&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT face="arial, helvetica, sans-serif"&gt;So your datastep will now create a single table, called "Public Health", instead of two tables, one called "Public" and the other called "Health". But you will then have to refer to it as "Public Health"n.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Dec 2017 19:24:01 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2017-12-07T19:24:01Z</dc:date>
    <item>
      <title>Separate Outputs not handling spaces(creates extra data set)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Outputs-not-handling-spaces-creates-extra-data-set/m-p/419215#M103056</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;infile&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;truncover&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; @&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; deptid &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; deptdescription $ &amp;amp; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 Maths&lt;/P&gt;
&lt;P&gt;2 Astronomy&lt;/P&gt;
&lt;P&gt;1 Maths&lt;/P&gt;
&lt;P&gt;3 Physics&lt;/P&gt;
&lt;P&gt;4 Public Health&lt;/P&gt;
&lt;P&gt;3 Physics&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* Sort by Deptid so first./last. logic can be used in the next step */&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; deptid;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* CALL SYMPUTX creates macro variables &amp;amp;Subj1, &amp;amp;Subj2, etc from the values of Deptdescription.*/&lt;/P&gt;
&lt;P&gt;/* The total unique values of Deptdescription are stored in &amp;amp;Total */&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; deptid;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; first.deptid &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; i+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symputx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'subj'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;|| left(put(i,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)),deptdescription);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; last.deptid &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symputx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'total'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,i);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* Within a macro %DO loop the data sets are created and those observations with the same */&lt;/P&gt;
&lt;P&gt;/* Deptdescription values are read with a WHERE clause */&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;test&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;total;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data &amp;amp;&amp;amp;subj&amp;amp;i;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; where deptdescription=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;&amp;amp;subj&amp;amp;i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* invoke the macro */&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;test&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The above process creates separate datasets based on the deptid and deptdescription.&amp;nbsp; The issue is Public Health is created twice (Public then Health) in separate datasets.&amp;nbsp; I tried using&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;length deptdescription $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;50&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt; in the macro test area however I still get separate datasets whenever there is a space in the variable name.&amp;nbsp; How can I address this?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Outputs-not-handling-spaces-creates-extra-data-set/m-p/419215#M103056</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2017-12-07T15:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Outputs not handling spaces(creates extra data set)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Outputs-not-handling-spaces-creates-extra-data-set/m-p/419221#M103059</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;If Subj = Public Health this becomes&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;&amp;amp;subj&amp;amp;i.;
&lt;BR /&gt;becomes:&lt;BR /&gt;
data public health; &amp;lt;- This is not valid&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Figure out how you want to name the data set and fix that step.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This post addresses the issue you're seeing&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Outputs-not-handling-spaces-creates-extra-data-set/m-p/419221#M103059</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-07T15:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Outputs not handling spaces(creates extra data set)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Outputs-not-handling-spaces-creates-extra-data-set/m-p/419303#M103085</link>
      <description>&lt;P&gt;You have two possibilities: Either you change the variable to a valid SAS version 7 (or earlier) name, or you use option VALIDVARNAME=ANY and use a quoted string for your data set name. The second solution may be easier, as you can use the same macro variable for the WHERE clause and the data set name:&lt;/P&gt;&lt;PRE&gt;data "&amp;amp;&amp;amp;subj&amp;amp;i"n;
  set have;
  where deptdescription="&amp;amp;&amp;amp;subj&amp;amp;i";&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT face="arial, helvetica, sans-serif"&gt;So your datastep will now create a single table, called "Public Health", instead of two tables, one called "Public" and the other called "Health". But you will then have to refer to it as "Public Health"n.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 19:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Outputs-not-handling-spaces-creates-extra-data-set/m-p/419303#M103085</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2017-12-07T19:24:01Z</dc:date>
    </item>
  </channel>
</rss>

