<?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 Default variable lengths &amp; including duplicates. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188076#M265811</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First off let me just say i am quite a novice with SAS and i'm using the studio version and studying it through a work scheme / online modules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a sas program which i have written to import 2 sheets and merge them together which it does successfully (to a point)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However i am having an issue whereby the column it inserts the data (similar to how a vlookup works) doesn't allow me to specify a length when creating it this column is totally empty in my input sheet as i then get the value from the other sheet. The error i get is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Consolas, Courier, 'Courier New'; font-size: 16px; background-color: #ffffff;"&gt; NOTE: The LENGTH attribute cannot be changed and is therefore being ignored.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Consolas, Courier, 'Courier New'; font-size: 16px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and the code i am using is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;proc import replace datafile= '/folders/myfolders/arron/tab.xlsx'&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;DBMS=xlsx OUT = work.tab;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;length agent $ 25;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am also then experiencing an issue whereby it lists the first value only and then moves onto the next agent leaving lots of blanks.&lt;/P&gt;&lt;P&gt;my code is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;data arron.tab;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;merge tab (in=a) agent_stores (in=b keep=store agent);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by store;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if a;&amp;nbsp;&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Store is the variable i reference within the agent_stores list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Nov 2014 19:45:54 GMT</pubDate>
    <dc:creator>a_dobbins</dc:creator>
    <dc:date>2014-11-26T19:45:54Z</dc:date>
    <item>
      <title>Default variable lengths &amp; including duplicates.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188076#M265811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First off let me just say i am quite a novice with SAS and i'm using the studio version and studying it through a work scheme / online modules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a sas program which i have written to import 2 sheets and merge them together which it does successfully (to a point)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However i am having an issue whereby the column it inserts the data (similar to how a vlookup works) doesn't allow me to specify a length when creating it this column is totally empty in my input sheet as i then get the value from the other sheet. The error i get is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Consolas, Courier, 'Courier New'; font-size: 16px; background-color: #ffffff;"&gt; NOTE: The LENGTH attribute cannot be changed and is therefore being ignored.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Consolas, Courier, 'Courier New'; font-size: 16px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and the code i am using is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;proc import replace datafile= '/folders/myfolders/arron/tab.xlsx'&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;DBMS=xlsx OUT = work.tab;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;length agent $ 25;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am also then experiencing an issue whereby it lists the first value only and then moves onto the next agent leaving lots of blanks.&lt;/P&gt;&lt;P&gt;my code is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;data arron.tab;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;merge tab (in=a) agent_stores (in=b keep=store agent);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by store;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if a;&amp;nbsp;&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #0000ff;"&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Store is the variable i reference within the agent_stores list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 19:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188076#M265811</guid>
      <dc:creator>a_dobbins</dc:creator>
      <dc:date>2014-11-26T19:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Default variable lengths &amp; including duplicates.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188077#M265812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't set the length of a variable in a proc import. You can add it after the import step in a data step or even your merge. It's hard to say about the merge, can you show an example of what's happening. You may need a SQL merge.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;proc import replace datafile= '/folders/myfolders/arron/tab.xlsx'&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;DBMS=xlsx OUT = work.tab;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;run;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;data tab2;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;set tab;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;&lt;EM style="color: #0000ff; font-family: inherit; background-color: #ffffff;"&gt; length agent $25.;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;run;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM style="font-family: inherit;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 20:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188077#M265812</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-26T20:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Default variable lengths &amp; including duplicates.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188078#M265813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using XSLX for your data can cause this type of problem because that is a spreadsheet and not a database.&amp;nbsp; So SAS has to guess at the variable types and lengths.&amp;nbsp; You cannot actually change that decision by adding a LENGTH statement to PROC IMPORT.&amp;nbsp; You would be better off adding code to force the variables to comply with your data specifications.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data agent_stores_fixed ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length agent $25 store $25 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set agent_stores ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=agent_stores_fixed; by store; run;&lt;/P&gt;&lt;P&gt;data tab_fixed;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length store $25 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set tab;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=tab_fixed; by store; run;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt; merge tab_fixed (in=in1) agent_stores(keep=store agent);&lt;/P&gt;&lt;P&gt; by store ;&lt;/P&gt;&lt;P&gt; if in1 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not clear what you mean by the merge not working, but the description sounds like a problem you might have if both tables have more than one row per store.&amp;nbsp; You cannot do a many to many merge using a simple data step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 20:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188078#M265813</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-11-26T20:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Default variable lengths &amp; including duplicates.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188079#M265814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Both. I have tried setting the lengths later on and the result is that the length is already set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i use a proc contents to view how its set up its shows the length as being 1 which is as a result of this column being blank in the excel sheet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the merge what i mean is i have 2 lists the agent_stores which is a store list and then agent name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with the tab list this shows 7 variables. Including the store name and a blank space for the agent name.&lt;/P&gt;&lt;P&gt;It inputs the agent name once for the store (well the first character anyway) and then leaves each one afterwards blank. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 20:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188079#M265814</guid>
      <dc:creator>a_dobbins</dc:creator>
      <dc:date>2014-11-26T20:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Default variable lengths &amp; including duplicates.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188080#M265815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To change the length you need to put the LENGTH statement before any other statement (like the SET or MERGE) that would define a length for the variable. Otherwise the LENGTH statement is ignored because the length has already been defined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to DROP the empty column.&amp;nbsp; The way that the MERGE statement manages to do a 1 to MANY merge is that the values from the 1 dataset are retained as new records from the MANY dataset are read.&amp;nbsp; But if the MANY dataset has the same variable then the value read from that dataset will overwrite the value that was retained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that just adding the DROP will fix both problems. The variable AGENT in ARRON.TAB is being defined as length=1 because the first definition of it is in data set TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM&gt;data arron.tab;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM&gt;merge tab (in=a &lt;STRONG&gt;drop=agent&lt;/STRONG&gt;) agent_stores (in=b keep=store agent);&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by store;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if a;&amp;nbsp; &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-family: inherit; color: #0000ff;"&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 21:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188080#M265815</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-11-26T21:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Default variable lengths &amp; including duplicates.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188081#M265816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great! That fixed both problems. Much appreciated Tom! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 21:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Default-variable-lengths-including-duplicates/m-p/188081#M265816</guid>
      <dc:creator>a_dobbins</dc:creator>
      <dc:date>2014-11-26T21:52:37Z</dc:date>
    </item>
  </channel>
</rss>

