<?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: Change few column name from another file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/517072#M139723</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/247321"&gt;@ashish112&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't make the same mistakes twice:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;In one of his earlier posts RW9 advised you to write ...memname='IMPORT3' ... -- you wrote 'import3' again in your latest program.&lt;/LI&gt;
&lt;LI&gt;You omitted the GUESSINGROWS statement again in the PROC IMPORT step reading data2.csv.&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Thu, 29 Nov 2018 15:17:40 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-11-29T15:17:40Z</dc:date>
    <item>
      <title>Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/515975#M139319</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on some SAS application, I have stuck in between where I have to change few column names from another file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In detail: I have attached two csv file here, Data1 and Data2.&amp;nbsp; I want to change few column names of Data1 file. The new name is available in Data2 file, column name "new name". I want to replace the old name to new name in Data1 file.&amp;nbsp; Need your help. It might be easy but I am new to SAS, so for me its difficult.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 13:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/515975#M139319</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-26T13:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/515976#M139320</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* UNTESTED CODE */
proc import datafile='data1.csv' dbms=csv out=data1;
run;

proc import datafile='data2.csv' dbms=csv out=_names_;
run;

proc sql noprint;
    select cats(old_name,'=',new_name) separated by ' ' into :renames from _names_;
quit;

proc datasets library=work nolist;
    modify data1;
    change &amp;amp;renames;
run; quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 13:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/515976#M139320</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-26T13:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/515989#M139323</link>
      <description>syntax error comes for cats function</description>
      <pubDate>Mon, 26 Nov 2018 14:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/515989#M139323</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-26T14:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516002#M139324</link>
      <description>&lt;P&gt;And this syntax error you have posted where?&amp;nbsp; We cannot guess these things, please post&amp;nbsp;&lt;STRONG&gt;all&lt;/STRONG&gt; information necessary, what code are you running, test data, log output etc.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 14:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516002#M139324</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-26T14:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516037#M139337</link>
      <description>proc sql print;&lt;BR /&gt;8186 select cats(evntkey,'=',code) separated by ' ' into:renames from conc;&lt;BR /&gt;_________&lt;BR /&gt;22&lt;BR /&gt;202&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?,&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Nov 2018 16:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516037#M139337</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-26T16:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516039#M139339</link>
      <description>&lt;P&gt;That is not the log.&amp;nbsp; There is something which is happening before the 8186 line - the fact the proc sql print; code line does not have a number before it is an indication that something else has happened.&amp;nbsp; Please post full log, or full code with test data.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 16:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516039#M139339</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-26T16:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516044#M139342</link>
      <description>&lt;P&gt;sas log attached here&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 16:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516044#M139342</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-26T16:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516047#M139344</link>
      <description>&lt;P&gt;Ah yes, separated should appear after into, e.g.&lt;/P&gt;
&lt;PRE&gt;proc sql print;
  select cats(name," ",sex) into :test separated by " " from sashelp.class;
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 16:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516047#M139344</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-26T16:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516048#M139345</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select cats(oldname,'=',newname) into :renames separated by ' ' from work.import1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My bad&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 16:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516048#M139345</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-26T16:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516055#M139352</link>
      <description>&lt;P&gt;Hi, thank you from quick response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is still one error, I have attached the log here. I am using sas university edition, do this make difference?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 17:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516055#M139352</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-26T17:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516076#M139358</link>
      <description>&lt;P&gt;Omit the libref (&lt;FONT face="courier new,courier"&gt;work&lt;/FONT&gt;) in the MODIFY statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;modify import;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is&amp;nbsp;general syntax of PROC DATASETS.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 18:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516076#M139358</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-26T18:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516222#M139390</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried this but there are multiple errors, I have attached the log here.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 04:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516222#M139390</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-27T04:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516244#M139404</link>
      <description>&lt;P&gt;I got this , we have to use "rename" instead of "Change".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this code is working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select cats(oldname,'=',newname) into :renames separated by ' ' from import1;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc datasets library= work nolist;&lt;BR /&gt;modify import;&lt;BR /&gt;rename &amp;amp;renames;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there is one more issue. If there is extra variables in data2 which is not in data 1 then it throws error. like,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasError focus-line"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: Variable AENF7 is not on file WORK.IMPORT.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;SPAN&gt;ERROR: Variable BENF2 is not on file WORK.IMPORT.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;the variables AENF7 BENF2 are not in data1 but available in data2&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Is there any way to solve this?&lt;/DIV&gt;</description>
      <pubDate>Tue, 27 Nov 2018 08:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516244#M139404</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-27T08:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516245#M139405</link>
      <description>&lt;P&gt;Then you will need to cross reference the sashelp metadata something like:&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
  select cats(oldname,'=',newname) 
  into   :renames separated by ' ' 
  from   import1
  where  upcase(oldname) in (select name from sashelp.vcolumn where libname="WORK" and memname="IMPORT2");
quit;

proc datasets library= work nolist;
modify import;
rename &amp;amp;renames;
run;
quit;&lt;/PRE&gt;
&lt;P&gt;Sashelp.vcolumns is the column metadata for all libraries in existence, so you can pull a list by providing the libname and dataset (normally uppercase) and then seeing if the variable is in that list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I would however say at this point is why do you have such a mess?&amp;nbsp; First off having the metdata in a seperate file to read is ok, but not ideal, but if that metadata doesn't even match the data what is the point?&amp;nbsp; A data transfer comprises of two parts one more important than the other.&amp;nbsp; The important part is the documentation containing a description of the data - completely and accurately. Without this data transfer is a failure.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 08:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516245#M139405</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-27T08:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516264#M139417</link>
      <description>&lt;P&gt;Hi, thanks for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I notice that there is still some weird errors, when we have variables like&lt;/P&gt;&lt;P&gt;AENF1&lt;/P&gt;&lt;P&gt;AENF2&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;AENF10&lt;/P&gt;&lt;P&gt;AENF11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then these codes not read AENF10 and AENF11, Its only read upto 5 character only and the error throws for more than 5 char variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the sas log here.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 09:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516264#M139417</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-27T09:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516265#M139418</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/247321"&gt;@ashish112&lt;/a&gt;: Add the statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;guessingrows=max;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to the PROC IMPORT step for data2.csv to avoid this truncation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, you will need the REPLACE option of the PROC IMPORT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 10:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516265#M139418</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-27T10:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516270#M139419</link>
      <description>&lt;P&gt;I have tried this still same error comes, see the attached log&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 10:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516270#M139419</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-27T10:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516280#M139426</link>
      <description>&lt;DIV&gt;2171 proc sql noprint;&lt;/DIV&gt;
&lt;DIV&gt;2172 select cats(oldname,'=',newname) into :renames separated by ' ' from work.import1&lt;/DIV&gt;
&lt;DIV&gt;2173 where upcase(oldname) in (select name from sashelp.vcolumn where libname="WORK" and memname="import3");&lt;/DIV&gt;
&lt;DIV&gt;NOTE: No rows were selected.&lt;/DIV&gt;
&lt;DIV&gt;2174 quit;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The above is not good, you note the "No rows were selected", that means nothing is created.&amp;nbsp; Probably you meant:&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;and memname="IMPORT3"&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Note, the string must match what is in the dataset sashelp.vcolumn!&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Also, where did import3 come in?&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 27 Nov 2018 11:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516280#M139426</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-27T11:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516281#M139427</link>
      <description>I have changed the dataset name for "data1.csv" to work.import3&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Nov 2018 11:28:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516281#M139427</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-27T11:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Change few column name from another file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516307#M139439</link>
      <description>&lt;P&gt;I am still working on solution, no success yet. My major concern is the error comes when there is extra variables in data2 file which are not in data1 file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any other solution?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 14:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-few-column-name-from-another-file/m-p/516307#M139439</guid>
      <dc:creator>ashish112</dc:creator>
      <dc:date>2018-11-27T14:01:24Z</dc:date>
    </item>
  </channel>
</rss>

