<?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 Creating lists with apostrophes from one proc import Excel in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857610#M42173</link>
    <description>&lt;P&gt;I have imported a list which is one variable and over 66k records (A1:A66000).&amp;nbsp; I then need to create a list adding an apostrophe in order to query these IDs in the next data step for how the field is stored as VARCHAR.&amp;nbsp; I am unable to create a list from the Proc Import since there are too many records.&amp;nbsp; It appears I may need to run this below step several times to use the list(s) in my where statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way in the below to add in a range from the proc import?&amp;nbsp; Then maybe I can have NPI_LIST1, NPI_LIST2, NPI_LIST3 etc?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I an make sure the excel import is clean enough so that I do not need to add the apostrophes and change the records to VARCHAR?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or is there a better solution I am not considering?&amp;nbsp; I am new to SAS so any guidance is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL:&lt;/P&gt;&lt;P&gt;Select&lt;/P&gt;&lt;P&gt;CATS(" ' ",NPI_ID," ' ") AS VARCHAR into: NPI_LIST1 separated by " ' "&lt;/P&gt;&lt;P&gt;From Work.npis;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2023 17:23:14 GMT</pubDate>
    <dc:creator>Gucci913</dc:creator>
    <dc:date>2023-02-07T17:23:14Z</dc:date>
    <item>
      <title>Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857610#M42173</link>
      <description>&lt;P&gt;I have imported a list which is one variable and over 66k records (A1:A66000).&amp;nbsp; I then need to create a list adding an apostrophe in order to query these IDs in the next data step for how the field is stored as VARCHAR.&amp;nbsp; I am unable to create a list from the Proc Import since there are too many records.&amp;nbsp; It appears I may need to run this below step several times to use the list(s) in my where statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way in the below to add in a range from the proc import?&amp;nbsp; Then maybe I can have NPI_LIST1, NPI_LIST2, NPI_LIST3 etc?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I an make sure the excel import is clean enough so that I do not need to add the apostrophes and change the records to VARCHAR?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or is there a better solution I am not considering?&amp;nbsp; I am new to SAS so any guidance is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL:&lt;/P&gt;&lt;P&gt;Select&lt;/P&gt;&lt;P&gt;CATS(" ' ",NPI_ID," ' ") AS VARCHAR into: NPI_LIST1 separated by " ' "&lt;/P&gt;&lt;P&gt;From Work.npis;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 17:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857610#M42173</guid>
      <dc:creator>Gucci913</dc:creator>
      <dc:date>2023-02-07T17:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857619#M42174</link>
      <description>&lt;P&gt;I am confused.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;First you say "&lt;SPAN&gt;I have imported a list which is one variable and over 66k records" — okay, that is clear. Then you say "I am unable to create a list from the Proc Import since there are too many records." How are you creating the list? Why are you creating the list? Why do you need to add an apostrophe?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 17:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857619#M42174</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-07T17:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857620#M42175</link>
      <description>&lt;P&gt;Sorry I was not clear.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The import works fine.&amp;nbsp; The problem is that I can not use the NPI_ID in the where statement because the field I am filtering on is stored as VARCHAR and it needs to have an apostrophe since that is how the field is formatted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine when the proc import is smaller. I think the limitation is 10,000.&amp;nbsp; Therefore I think I need to create multiple Lists.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of importing several files, to then create the lists casting them as VARCHAR and adding an apostrophe I am trying to determine if there is a better solution.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Does that help?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 17:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857620#M42175</guid>
      <dc:creator>Gucci913</dc:creator>
      <dc:date>2023-02-07T17:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857623#M42177</link>
      <description>&lt;P&gt;Macro variables are limited in size to 64k characters. Use the imported dataset in a join or sub-select, or read it into a hash object to do the subsetting.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 18:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857623#M42177</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-07T18:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857631#M42178</link>
      <description>&lt;P&gt;Why do you want to stuff data into macro variable(s)?&lt;/P&gt;
&lt;P&gt;Why can't you just use the data from the dataset?&amp;nbsp; What are you going to do with this list of values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to generate a string like 'A','B', .... that is going to be longer than the 64K byte limit of a single macro variable then you will need to use multiple macro variables.&amp;nbsp; Like this example:&lt;/P&gt;
&lt;PRE&gt;891  data _null_;
892    call symputx('list1',"'A','B'");
893    call symputx('list2',"'C','D'");
894    call symputx('list','&amp;amp;list1,&amp;amp;list2');
895  run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


896
897  %put &amp;amp;=list1 &amp;amp;=list1 &amp;amp;=list;
LIST1='A','B' LIST1='A','B' LIST='A','B','C','D'
898  %put LIST=%superq(list);
LIST=&amp;amp;list1,&amp;amp;list2
&lt;/PRE&gt;
&lt;P&gt;You can use a data step to generate the need macro variables.&lt;/P&gt;
&lt;P&gt;Let's make up some sample data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id $10.;
cards;
ABCD
EFGH
IJKL
MNOP
QRST
UVWX
YZ
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now let's convert into macro variables with a maximum length of 20 bytes each.&amp;nbsp; Note that a dataset variable has a maximum length of only 32K bytes (half of the maximum length of a macro variable).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let maxlen=20 ;
data _null_;
  length string $%sysfunc(min(32767,%sysfunc(max(&amp;amp;maxlen,1000))));
  retain string;
  do until(eof or toolong) ;
    set have end=eof;
    qid=quote(trim(id),"'");
    toolong=length(catx(',',string,qid))&amp;gt;&amp;amp;maxlen ;
    if toolong then do;
      listnum+1;
      call symputx(cats('list',listnum),string);
      string=qid;
    end;
    else string=catx(',',string,qid);
  end;
  if eof then do;
    if toolong then do;
      listnum+1;
      call symputx(cats('list',listnum),string);
    end;
    string=' ';
    do i=1 to listnum;
      string=catx(',',string,cats('&amp;amp;list',i));
    end;
    call symputx('listnum',listnum);
    call symputx('list',string);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's check the results:&lt;/P&gt;
&lt;PRE&gt;1574  %put &amp;amp;=listnum &amp;amp;=list;
LISTNUM=3 LIST='ABCD','EFGH','IJKL','MNOP','QRST','UVWX','YZ'
1575  %put %superq(list);
&amp;amp;list1,&amp;amp;list2,&amp;amp;list3
1576  %put &amp;amp;=list1 ;
LIST1='ABCD','EFGH','IJKL'
1577  %put LIST&amp;amp;listnum=&amp;amp;&amp;amp;list&amp;amp;listnum;
LIST3='YZ'
&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2023 18:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857631#M42178</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-07T18:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857636#M42179</link>
      <description>Thx for your suggestions. The join does not work because the components are of different data types (my main issue). I am not sure how to use hash object but I am going to look into it.</description>
      <pubDate>Tue, 07 Feb 2023 18:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857636#M42179</guid>
      <dc:creator>Gucci913</dc:creator>
      <dc:date>2023-02-07T18:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857637#M42180</link>
      <description>Thank you for taking the time to document the steps, admittedly its over my head. The excel file I am using as a dataset is not stored the same way as my data set. I am not sure how to fix this, therefore my workaround was the macro to generate a string... it works but not without creating the step many times into various lists.</description>
      <pubDate>Tue, 07 Feb 2023 18:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857637#M42180</guid>
      <dc:creator>Gucci913</dc:creator>
      <dc:date>2023-02-07T18:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857639#M42181</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/439274"&gt;@Gucci913&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for taking the time to document the steps, admittedly its over my head. The excel file I am using as a dataset is not stored the same way as my data set. I am not sure how to fix this, therefore my workaround was the macro to generate a string... it works but not without creating the step many times into various lists.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to explain more about what is wrong.&amp;nbsp; SAS only has TWO data types.&amp;nbsp; So there are only THREE combinations you could have.&amp;nbsp; Both character, Both numeric and one character and one numeric.&amp;nbsp; Any of them is easy to work with using SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table want as 
  select * 
  from have1 inner join have2
  on have1.charvar1 = have2.charvar2
;
create table want as 
  select * 
  from have1 inner join have2
  on have1.numvar1 = have2.numvar2
;
create table want as 
  select * 
  from have1 inner join have2
  on have1.input(charvar1,32.) = have2.numvar1
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2023 18:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857639#M42181</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-07T18:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857640#M42182</link>
      <description>&lt;P&gt;In SAS SQL you can join columns with different data types by using either the PUT or INPUT function in the join syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table Want as 
  select *
  from Have1 as A
  left join Have2 as B
  on put(A.ID_Num, 8.) = B.ID_Char;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2023 19:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857640#M42182</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-02-07T19:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857689#M42183</link>
      <description>&lt;P&gt;Let's start at the beginning: Excel files are the worst means of data transfer, as the tools available for import have to make guesses about data types and attributes. The best way to work around this is to save the data as text (.csv) which enables you to read it with a DATA step where&amp;nbsp;&lt;EM&gt;you&lt;/EM&gt; set all the attributes so they match the data you already have (use PROC CONTENTS on your existing data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To provide sample code for the use of hash objects, we need to see examples of your data. Ideally, you post these as DATA steps with DATALINES, so we can recreate your datasets with a simple copy/paste and submit. Do not use Excel attachments or pictures.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 06:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857689#M42183</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-08T06:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lists with apostrophes from one proc import Excel</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857749#M42185</link>
      <description>This is amazing! Thank you thank you !</description>
      <pubDate>Wed, 08 Feb 2023 13:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-lists-with-apostrophes-from-one-proc-import-Excel/m-p/857749#M42185</guid>
      <dc:creator>Gucci913</dc:creator>
      <dc:date>2023-02-08T13:52:40Z</dc:date>
    </item>
  </channel>
</rss>

