<?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: Creating labels for 300+ variables in dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702925#M215327</link>
    <description>You need just one solution, and you do need to import the data from Excel into SAS to use it with either dynamic method except the copy/paste option.</description>
    <pubDate>Tue, 01 Dec 2020 23:15:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-12-01T23:15:39Z</dc:date>
    <item>
      <title>Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702903#M215314</link>
      <description>&lt;P&gt;I am a beginner to SAS - I am not super familiar with macros.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create labels for 300+ variables in my dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable names and labels are stored both in a textfile, and an excel file&lt;BR /&gt;(Column 1 is the variable name, column 2 is the associated label)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I go about doing this? Are macros the best solution?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 22:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702903#M215314</guid>
      <dc:creator>Pre1</dc:creator>
      <dc:date>2020-12-01T22:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702904#M215315</link>
      <description>&lt;P&gt;You can create the PROC DATASETS code in a DATA _NULL_ step with CALL EXECUTE, or write it to an external file that you later execute with %INCLUDE.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 22:09:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702904#M215315</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-01T22:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702905#M215316</link>
      <description>Here's one way. &lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/f18931085f6a0009185c" target="_blank"&gt;https://gist.github.com/statgeek/f18931085f6a0009185c&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Because you have 300 variables the macro approach may not work exactly as shown, you may need to loop each rename or use CALL EXECUTE instead. If you search on here, I know I've coded that solution at least twice &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 01 Dec 2020 22:16:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702905#M215316</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-01T22:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702906#M215317</link>
      <description>And the really quick &amp;amp; lazy solution, in Excel, create a new column and add in the function that does the following:&lt;BR /&gt;&lt;BR /&gt;=concatenate(variablename, " = ", "'", variableLabel, "'")&lt;BR /&gt;&lt;BR /&gt;That should create the text as follows in your Excel file:&lt;BR /&gt;&lt;BR /&gt;age = 'Age in Years'&lt;BR /&gt;name = 'Name'&lt;BR /&gt;weight = 'Weight(lbs)'&lt;BR /&gt;&lt;BR /&gt;Label + copy paste that new column from excel + semicolon and you're done.</description>
      <pubDate>Tue, 01 Dec 2020 22:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702906#M215317</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-01T22:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702907#M215318</link>
      <description>And just copy and paste that into SAS? That's doable but I guess the code will be very long</description>
      <pubDate>Tue, 01 Dec 2020 22:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702907#M215318</guid>
      <dc:creator>Pre1</dc:creator>
      <dc:date>2020-12-01T22:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702911#M215320</link>
      <description>Thank you, so something like this?&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/td-p/385698" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/td-p/385698&lt;/A&gt; Would I need the code you linked, or just this one? For both to work, I have to import the excel with the names into SAS as a separate dataset, right?</description>
      <pubDate>Tue, 01 Dec 2020 22:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702911#M215320</guid>
      <dc:creator>Pre1</dc:creator>
      <dc:date>2020-12-01T22:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702912#M215321</link>
      <description>&lt;P&gt;Let's say your text file of varnames and labels in the format in my datalines data below.&amp;nbsp; Then you could read that text file and write the properly composed components of a label statement to a temporary file.&amp;nbsp; That temporary file can be %INCLUDEd in a PROC DATASETS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename lbls temp;
data _null_;
  input vname :$32. vlabel &amp;amp;$60.;
  file lbls;
  put @4 vname    @38 "='" vlabel "'";

datalines;
aaaaa        This is a label for aaaaa
bbbbbbbbbbb  This is a label for bbbbbbbbbbb
run;


proc datasets library=mylib nolist;
  modify have;
  label
  %include lbls /source2; 
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program assumes&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;you have a dataset named mylib.have which contains variables aaaaa and bbbbbbbbbbb.&lt;/LI&gt;
&lt;LI&gt;Your text file of varnames and labels looks like my datalines data.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Other notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The filename lbls is assigned the TEMP attribute, which means it will be deleted at the end of your sas session.&amp;nbsp; You don't need to do housekeeping.&lt;/LI&gt;
&lt;LI&gt;The label statement in the proc datasets has three components:
&lt;OL&gt;
&lt;LI&gt;The command "label"&lt;/LI&gt;
&lt;LI&gt;The %INCLUDEd text from the lbls file, which was generated in the prior data step.&lt;/LI&gt;
&lt;LI&gt;Two (!!) semicolons - one to terminate the %include statement, and the other to terminate the multi-component label statement.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 01 Dec 2020 22:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702912#M215321</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-12-01T22:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702925#M215327</link>
      <description>You need just one solution, and you do need to import the data from Excel into SAS to use it with either dynamic method except the copy/paste option.</description>
      <pubDate>Tue, 01 Dec 2020 23:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702925#M215327</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-01T23:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating labels for 300+ variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702930#M215331</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/300343"&gt;@Pre1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;And just copy and paste that into SAS? That's doable but I guess the code will be very long&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Only 300? Not that long.&lt;/P&gt;
&lt;P&gt;I had projects using provided documentation that used the "write code in excel" to create labels for way more variables than that. And to create the SAS variable names from some way-too-long text (120 characters in some cases), the input statement and informat as well. Something like 2600 lines of data step code. Almost everything except the Data , Infile and Run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which is possible with people that actually document stuff and will provide the documentation before guessing what is in the raw files.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 23:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-labels-for-300-variables-in-dataset/m-p/702930#M215331</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-01T23:31:28Z</dc:date>
    </item>
  </channel>
</rss>

