<?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: Adding Variable Names to SAS Dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436746#M69002</link>
    <description>&lt;P&gt;If you already have the factsetnames file then there isn't anything tedious about the code at all. Here is the same code, but which uses the already created factsetnames file. It would accomplish the renaming for all of the variables in the factsetnames file:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  length forexec $255;
  set FactSetNames end=eof;
  if _n_ eq 1 then call execute ("data Need; set Actual;");
  forexec=catt("rename var",_n_,"=",FileNames,";");
  call execute(forexec);
  if eof then call execute ("run;");
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Feb 2018 15:24:38 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2018-02-13T15:24:38Z</dc:date>
    <item>
      <title>Adding Variable Names to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436704#M68996</link>
      <description>&lt;P&gt;Hello Community!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to replace SAS variable names for a dataset that has been loaded to the server. For instance, SAS dataset (Var1, Var2, Var3, Var4, etc.). Need to change Var"" to: CustomerNo., CustName, Product, Sale, etc.. No need to do import because the table is already available in on the server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;"abc.filename"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have. Where have I gone wrong?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Actual&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Var1&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Var2&amp;nbsp;&lt;/U&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Var3&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Var4&lt;/U&gt;&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Ted&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Knife&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $25&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Bill&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Watch&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $55&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Need&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;CustomerNo&amp;nbsp;&lt;/U&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;CustName&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Product&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Sale&lt;/U&gt;&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Ted&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Knife&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$25&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Bill&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Watch&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$55&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; FactSetNames;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input FileNames $30.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CustomerNo&lt;/P&gt;&lt;P&gt;CustName&lt;/P&gt;&lt;P&gt;Product&lt;/P&gt;&lt;P&gt;Sale&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt; &lt;STRONG&gt;&lt;EM&gt;FactSetloop&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i = &lt;STRONG&gt;1&lt;/STRONG&gt; %to &lt;STRONG&gt;255&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set FactSetNames;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _N_ = &amp;amp;i then call symputx("FileName",FileNames,'G');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FFFF00"&gt; &lt;STRONG&gt;&amp;nbsp;&lt;FONT color="#FF0000"&gt; Data step?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;FactSetloop&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 14:18:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436704#M68996</guid>
      <dc:creator>DrBigAl</dc:creator>
      <dc:date>2018-02-13T14:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variable Names to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436709#M68997</link>
      <description>&lt;P&gt;Why are they being loaded in as var1 var2 in the first place?&amp;nbsp; Fix the broken part, don't try to repair it after the fact.&amp;nbsp; I suspect its likely your importing a spreadsheet.&amp;nbsp; Bin that, import a csv and write a datastep to do the process.&amp;nbsp; That way you can read in the data you want, set labels, names and lengths etc. at load time.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 14:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436709#M68997</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-13T14:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variable Names to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436718#M68998</link>
      <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  length forexec $255;
  input FileNames $30.;
  if _n_ eq 1 then call execute ("data Need; set Actual;");
  forexec=catt("rename var",_n_,"=",FileNames,";");
  call execute(forexec);
  if _n_ eq 4 then call execute ("run;");
  datalines;
CustomerNo
CustName
Product
Sale 
;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 14:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436718#M68998</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-13T14:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variable Names to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436720#M68999</link>
      <description>&lt;P&gt;Where did you go wrong?&amp;nbsp; By starting to write a program.&amp;nbsp; First, you should have read related pieces of the manual, so you would have an idea of what the program should look like.&amp;nbsp; Some topics:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RENAME statement&lt;/P&gt;
&lt;P&gt;The RENAME= option on a SET statement&lt;/P&gt;
&lt;P&gt;The MODIFY statement within PROC DATASETS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have some idea of what the program should look like, you can begin the programming.&amp;nbsp; One related hint:&amp;nbsp; you would need two variables in&amp;nbsp;a SAS data set, for example, OLDNAME and NEWNAME.&amp;nbsp; They should both be character, 32 characters long (maximum length for a variable name in SAS).&amp;nbsp; A single variable (FileNames) is not enough.&amp;nbsp; So when OLDNAME is Var1, NEWNAME would be CustomerNo.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 14:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436720#M68999</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-13T14:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variable Names to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436740#M69000</link>
      <description>The dataset was loaded by another person. I only have a seperate variable name key. Don't have access to the original file</description>
      <pubDate>Tue, 13 Feb 2018 15:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436740#M69000</guid>
      <dc:creator>DrBigAl</dc:creator>
      <dc:date>2018-02-13T15:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variable Names to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436741#M69001</link>
      <description>Thank you for your solution. The problem is, I forgot to state, is that there are 150 variable names which doing each one is tedious and time consuming.</description>
      <pubDate>Tue, 13 Feb 2018 15:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436741#M69001</guid>
      <dc:creator>DrBigAl</dc:creator>
      <dc:date>2018-02-13T15:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variable Names to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436746#M69002</link>
      <description>&lt;P&gt;If you already have the factsetnames file then there isn't anything tedious about the code at all. Here is the same code, but which uses the already created factsetnames file. It would accomplish the renaming for all of the variables in the factsetnames file:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  length forexec $255;
  set FactSetNames end=eof;
  if _n_ eq 1 then call execute ("data Need; set Actual;");
  forexec=catt("rename var",_n_,"=",FileNames,";");
  call execute(forexec);
  if eof then call execute ("run;");
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 15:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436746#M69002</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-13T15:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variable Names to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436786#M69004</link>
      <description>&lt;P&gt;Code worked marvelously! Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 17:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Variable-Names-to-SAS-Dataset/m-p/436786#M69004</guid>
      <dc:creator>DrBigAl</dc:creator>
      <dc:date>2018-02-13T17:19:47Z</dc:date>
    </item>
  </channel>
</rss>

