<?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 indsname= and n-literal in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/877309#M346592</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Did I miss something here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the n-literal syntax is used to read an Excel worksheet having a name with 31 characters including blanks, quotations marks and n (n-literal syntax) are added in the temporary variable defined by indsname=. However, this variable has 41 characters by default i.e. 8 for the libname, 32 for the dataset name and 1 for the dot. The final quote and n are truncated if the libref is 8 character long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But increasing the variable length of the permanent variable storing the temporary variable to 43 characters does not solve the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any workaround e.g. an extra option to use here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
libname testwxyz xlsx "&amp;amp;xxtest./xlsxengine31.xlsx";

data testwxyz.'_23456789 123456789 12345678xyz'n;
    set sashelp.class;
run;

libname testwxyz clear;


libname testwxyz xlsx "&amp;amp;xxtest/xlsxengine31.xlsx";

data test;
    set testwxyz.'_23456789 123456789 12345678xyz'n (where=(sex='M'))
        testwxyz.'_23456789 123456789 12345678xyz'n (where=(sex='F')) 
        indsname=_tmp;
    length chk $43;
    chk=_tmp;
run;

libname testwxyz clear;

proc print data=test noobs;
run;

ods select position;
proc contents data=test varnum;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 May 2023 16:23:12 GMT</pubDate>
    <dc:creator>xxformat_com</dc:creator>
    <dc:date>2023-05-24T16:23:12Z</dc:date>
    <item>
      <title>indsname= and n-literal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/877309#M346592</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Did I miss something here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the n-literal syntax is used to read an Excel worksheet having a name with 31 characters including blanks, quotations marks and n (n-literal syntax) are added in the temporary variable defined by indsname=. However, this variable has 41 characters by default i.e. 8 for the libname, 32 for the dataset name and 1 for the dot. The final quote and n are truncated if the libref is 8 character long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But increasing the variable length of the permanent variable storing the temporary variable to 43 characters does not solve the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any workaround e.g. an extra option to use here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
libname testwxyz xlsx "&amp;amp;xxtest./xlsxengine31.xlsx";

data testwxyz.'_23456789 123456789 12345678xyz'n;
    set sashelp.class;
run;

libname testwxyz clear;


libname testwxyz xlsx "&amp;amp;xxtest/xlsxengine31.xlsx";

data test;
    set testwxyz.'_23456789 123456789 12345678xyz'n (where=(sex='M'))
        testwxyz.'_23456789 123456789 12345678xyz'n (where=(sex='F')) 
        indsname=_tmp;
    length chk $43;
    chk=_tmp;
run;

libname testwxyz clear;

proc print data=test noobs;
run;

ods select position;
proc contents data=test varnum;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 May 2023 16:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/877309#M346592</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2023-05-24T16:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: indsname= and n-literal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/877311#M346593</link>
      <description>Don't you need 44?&lt;BR /&gt;&lt;BR /&gt;2 quotes&lt;BR /&gt;1 period&lt;BR /&gt;1 n&lt;BR /&gt;32 characters&lt;BR /&gt;8 libname&lt;BR /&gt;=44 characters. I'd set it to 50 just to test it anyways.&lt;BR /&gt;&lt;BR /&gt;Move the length before the SET statement and apply it to both the _tmp and chk variables.</description>
      <pubDate>Wed, 24 May 2023 16:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/877311#M346593</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-24T16:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: indsname= and n-literal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/877318#M346596</link>
      <description>&lt;P&gt;You seem to have found a BUG in the INDSNAME= option.&amp;nbsp; It will not produce more than 41 characters no matter what length you define for the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if this is a serious concern for you then you might need to use some other method to capture the contributing dataset's name.&amp;nbsp; For example create views using shorter names and set the views and then translate the short name back to the original name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;To really be sure there is enough room for a full dataset name you need to use a length of 76.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The maximum length of libref is 8.&amp;nbsp; The period takes 1.&amp;nbsp; Plus 32 for the actual name. 3 for the outer quotes&amp;nbsp; and the letter N. And if you use the sub-optimal choice for which outer quote you might need to double up to all 32 of the characters in the actual name.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt; 70         data _null_;
 71           length name $32 nliteral $80;
 72           name=repeat("'",31);
 73           nliteral=cats('L2345678.',quote(name,"'"),'n');
 74           len = length(nliteral);
 75           call symputx('name',nliteral);
 76           put len=;
 77         run;
 
 len=76&lt;/PRE&gt;
&lt;P&gt;Let's try using that goofy name and we can see the truncation to 41 bytes actually happen.&lt;/P&gt;
&lt;PRE&gt;1973  libname L2345678 (WORK);
NOTE: Libref L2345678 was successfully assigned as follows:
      Levels:           1
      Engine(1):        V9
      Physical Name(1): C:\Users\...
1974
1975  data &amp;amp;name ;
1976   x=3;
1977  run;

NOTE: The data set L2345678.''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''n has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


1978
1979  data test;
1980    length dsn indsn $80 ;
1981    set &amp;amp;name indsname=indsn;
1982    dsn=indsn;
1983    len=length(dsn);
1984    put x= len= dsn= ;
1985  run;

x=3 len=41 dsn=L2345678.''''''''''''''''''''''''''''''''
NOTE: There were 1 observations read from the data set L2345678.''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''n.
NOTE: The data set WORK.TEST has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 17:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/877318#M346596</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-24T17:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: indsname= and n-literal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/880589#M347929</link>
      <description>yes, 44 is what I should have written. but the issue remains.</description>
      <pubDate>Wed, 14 Jun 2023 07:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/indsname-and-n-literal/m-p/880589#M347929</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2023-06-14T07:56:46Z</dc:date>
    </item>
  </channel>
</rss>

