<?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: How do I create LABEL for large no of Variables ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385822#M92338</link>
    <description>&lt;P&gt;I have Used 2 datasets which are in Assign library.&lt;/P&gt;&lt;P&gt;PSTN_FIle&lt;/P&gt;&lt;P&gt;Labels&lt;/P&gt;&lt;P&gt;I have Imported them in Assign library (Using SAS University edition)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Used following code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set ASSIGN.LABELS end=last;&lt;BR /&gt;if _n_=1 then call execute('proc datasets library=ASSIGN nolist nodetails ; modify ASSIGN.PSTN_FILE; label');&lt;BR /&gt;call execute(cats(Variable,'=',label));&lt;BR /&gt;if last then call execute(';quit;');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's still giving me erros !! any help ?&lt;/P&gt;</description>
    <pubDate>Sat, 05 Aug 2017 11:59:47 GMT</pubDate>
    <dc:creator>Deepak03</dc:creator>
    <dc:date>2017-08-05T11:59:47Z</dc:date>
    <item>
      <title>How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385698#M92296</link>
      <description>&lt;P&gt;I have a dataset with 500 variables, How can I label them without using conventional method of labeling each variable, which is time consuming.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385698#M92296</guid>
      <dc:creator>Deepak03</dc:creator>
      <dc:date>2017-08-04T16:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385701#M92298</link>
      <description>&lt;P&gt;500 variables seems a lot, do you think thats the best data model for what you have, I mean you have already hit labelling them, how are you going to work with such a vast number of variables? &amp;nbsp;As for how to do this, without any information of how your labels are stored, what the data looks like its impossible to say, if the labels are not in the computer, then typing them in is the only method, if they are stored somewhere, then you could generate the code:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set label_data end=last;
  if _n_=1 then call execute('proc datasets lib=test;');
  call execute('label '||strip(name)||'="'||strip(label)||'";');
  if last then call execute('run;');
run;&lt;/PRE&gt;
&lt;P&gt;Of course this assumes data is in lib temp, you have a dataset with name and label.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385701#M92298</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-04T16:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385704#M92301</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, large no of variables and I do have Label stored in another Excel,Will work on this code.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385704#M92301</guid>
      <dc:creator>Deepak03</dc:creator>
      <dc:date>2017-08-04T16:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385713#M92304</link>
      <description>&lt;P&gt;Use the data to create the LABEL statement(s).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set metadata ;
  put 'label ' name '=' label :$quote. ';' ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use them in your code. Either in the step that makes the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata ;
  length ..... ;
  input .... ;
%include code / source2 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use PROC DATASETS to apply them to an existing dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=work nolist ;
modify mydata ;
%include code / source2;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385713#M92304</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-04T16:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385721#M92308</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/157415"&gt;@Deepak03&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, large no of variables and I do have Label stored in another Excel,Will work on this code.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have used Excel formulas to combine the variable name and text for a label to create SAS Label syntax. And then copy/ paste into the SAS editor. the formula would look like this in EXCEL&lt;/P&gt;
&lt;PRE&gt;=D134&amp;amp;" = """&amp;amp;H134&amp;amp;""""&lt;/PRE&gt;
&lt;P&gt;The multiple quotes are so the resolved value puts the quotes around the label protion. In the above column D has variable names and&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;column H had the text of the label.&lt;/P&gt;
&lt;P&gt;I could then copy all of the rows with label and paste into SAS.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385721#M92308</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-04T17:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385822#M92338</link>
      <description>&lt;P&gt;I have Used 2 datasets which are in Assign library.&lt;/P&gt;&lt;P&gt;PSTN_FIle&lt;/P&gt;&lt;P&gt;Labels&lt;/P&gt;&lt;P&gt;I have Imported them in Assign library (Using SAS University edition)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Used following code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set ASSIGN.LABELS end=last;&lt;BR /&gt;if _n_=1 then call execute('proc datasets library=ASSIGN nolist nodetails ; modify ASSIGN.PSTN_FILE; label');&lt;BR /&gt;call execute(cats(Variable,'=',label));&lt;BR /&gt;if last then call execute(';quit;');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's still giving me erros !! any help ?&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 11:59:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385822#M92338</guid>
      <dc:creator>Deepak03</dc:creator>
      <dc:date>2017-08-05T11:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385823#M92339</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/157415"&gt;@Deepak03&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You need to provide sample data for us. I suggest you post two data steps creating such data.&lt;/P&gt;
&lt;P&gt;Data step one creates some sample data with - let's say - three variables, data step two creates the data with the labels for this three variables.&lt;/P&gt;
&lt;P&gt;Make sure you use names which are close to what you have in your real data as this will it make easier for you to then transition our propositions to your real data and code.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 12:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385823#M92339</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-08-05T12:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385824#M92340</link>
      <description>&lt;P&gt;Sample Fies attached , File to be modified is Sample 2&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 12:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385824#M92340</guid>
      <dc:creator>Deepak03</dc:creator>
      <dc:date>2017-08-05T12:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385849#M92345</link>
      <description>&lt;P&gt;Do not attach data as files. Paste the code to create the data into the Insert SAS code box. Something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample1;
  length Variable $32 Label $200 ;
  infile datalines dsd dlm='|' truncover ;
  input variable label;
datalines;
PRODUCT_ID|Line number
Year|Year
AON|Age on network
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 15:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385849#M92345</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-05T15:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385882#M92360</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/157415"&gt;@Deepak03&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Something like below should work (same as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;already posted):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename codegen temp;
data _null_;
  file codegen;
  set labels end=last;
  if _n_=1 then put 'attrib';
  put variable "label ='" label +(-1) "'";
  if last then put ";";
run;

data have;
  set have;
  %include codegen / source2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2017 00:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385882#M92360</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-08-06T00:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create LABEL for large no of Variables ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385883#M92361</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/157415"&gt;@Deepak03&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have Used 2 datasets which are in Assign library.&lt;/P&gt;
&lt;P&gt;PSTN_FIle&lt;/P&gt;
&lt;P&gt;Labels&lt;/P&gt;
&lt;P&gt;I have Imported them in Assign library (Using SAS University edition)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Used following code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set ASSIGN.LABELS end=last;&lt;BR /&gt;if _n_=1 then call execute('proc datasets library=ASSIGN nolist nodetails ; modify ASSIGN.PSTN_FILE; label');&lt;BR /&gt;call execute(cats(Variable,'=',label));&lt;BR /&gt;if last then call execute(';quit;');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's still giving me erros !! any help ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The MODIFY statement in PROC DATASETS just wants the membername, not the full two level name.&lt;/P&gt;
&lt;P&gt;You need quotes around the label value since it wants a string literal.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set ASSIGN.LABELS end=last;
  if _n_=1 then do;
    call execute('proc datasets library=ASSIGN nolist nodetails ;');
    call execute('modify PSTN_FILE; label');
  end;
  call execute(cats(Variable,'=',quote(trim(label))));
  if last then call execute(';quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2017 01:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-LABEL-for-large-no-of-Variables/m-p/385883#M92361</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-06T01:37:13Z</dc:date>
    </item>
  </channel>
</rss>

