<?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: proc sql create table select with a blank column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946591#M370695</link>
    <description>&lt;P&gt;Why use SQL?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length New_Field $50 ;
  set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Oct 2024 18:26:55 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-10-07T18:26:55Z</dc:date>
    <item>
      <title>proc sql create table select with a blank column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946582#M370688</link>
      <description>&lt;P&gt;Hello!&amp;nbsp; I am trying to run a proc sql with a select, so that I can grab all fields from another table, and also include a new 50 long character "blank" column.&amp;nbsp; &amp;nbsp;This code is giving errors, any ideas for fix, please?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql ;&lt;BR /&gt;Create Table Want as&lt;BR /&gt;Select&lt;BR /&gt;'' as 'New_Field' format $50.,&lt;BR /&gt;*&lt;BR /&gt;From Have; &lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ERROR 22-322: Expecting a name.  

ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 17:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946582#M370688</guid>
      <dc:creator>Rebecca_K</dc:creator>
      <dc:date>2024-10-07T17:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create table select with a blank column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946585#M370691</link>
      <description>&lt;P&gt;If you are going to use name literals then you end them with an N immediately after the closing quote:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql ;
Create Table Want as
Select
'' as 'New_Field'&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;n&lt;/STRONG&gt;&lt;/FONT&gt; format $50.,
*
From Have; 
quit;&lt;/PRE&gt;
&lt;P&gt;This will require the system options VALIDVARNAME=ANY if not already set.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 17:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946585#M370691</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-07T17:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create table select with a blank column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946586#M370692</link>
      <description>&lt;PRE&gt;proc sql ;
Create Table Want as
Select
'' as 'New_Field'n &lt;FONT color="#FF0000"&gt;length=&lt;/FONT&gt;50,
*
From Have; 
quit;&lt;/PRE&gt;
&lt;P&gt;You don't new to include NEW_FIELD inside quotes followed by the letter N, simply use New_Field as the name. Don't make your code more difficult to type than it needs to be.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 18:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946586#M370692</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-07T18:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create table select with a blank column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946587#M370693</link>
      <description>&lt;P&gt;No quotes around variable names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
Create Table Want as
Select
'' as New_Field length=50,
*
From Have; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And do not use formats to define the length.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 18:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946587#M370693</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-07T18:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create table select with a blank column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946590#M370694</link>
      <description>&lt;P&gt;Use the LENGTH option to set the length.&amp;nbsp; There is no need to attach a format as SAS already knows how to display character strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No need to place the quotes next to each other when typing the string literal for the blank string. SAS variables are fixed length and padded with spaces.&amp;nbsp; &amp;nbsp;So just use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;' '&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to indicate an blank string and you won't get confused looking at the code whether that is two single quote characters next to each other or one double quote character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No need to add quotes around the variable name (as long as it is a valid SAS name).&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table want as
  select ' ' as New_Field length=50
       , have.*
  from have
; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the name is non standard then you could either use a name literal.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;' ' as 'New_Field'n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or add the DQUOTE=ANSI option to the PROC SQL statement and use double quote characters around the variable name.&amp;nbsp; But in that case make sure to use single quotes for any string literals.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql dquote=ansi;
create table want as
  select ' ' as "New_Field" length=50
       , have.*
  from have
; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note if you do want to create a variable name like 'New Field'n then make sure you have set the VALIDVARNAME option to ANY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 18:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946590#M370694</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-07T18:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create table select with a blank column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946591#M370695</link>
      <description>&lt;P&gt;Why use SQL?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length New_Field $50 ;
  set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Oct 2024 18:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946591#M370695</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-07T18:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create table select with a blank column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946592#M370696</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;... will require the system options VALIDVARNAME=ANY if not already set.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Only if the name is non-standard.&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname='V7';
proc sql;
create table want as
  select ' ' as 'new_field'n length=50
       , getoption('validvarname') as varname length=5
       , *
  from sashelp.class(obs=1)
;
quit;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Oct 2024 18:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-table-select-with-a-blank-column/m-p/946592#M370696</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-07T18:34:18Z</dc:date>
    </item>
  </channel>
</rss>

