<?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: Automate the length of multiple character variables in a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810311#M319547</link>
    <description>&lt;P&gt;Because I want to apply a program that retrieves the name of the variable_name of the modality. For example male_sex. But it turns out that some variables have length 3, so doing so cuts off the name of the new modality.&lt;/P&gt;
&lt;P&gt;For example the sex variable has a length of 7, by applying my program I find sex_ho.&lt;BR /&gt;Image that I have a variable of length 3 but its name has 5 characters, with my program it will not take its modalities.&lt;/P&gt;
&lt;P&gt;For example: sales of yes/no modalities, the result will be sal instead of sales_oui.&lt;/P&gt;
&lt;P&gt;Reason for which, I wish to define a maximum length of 70 like that, all my program will give me the result which I seek.&lt;/P&gt;
&lt;P&gt;Waiting for your contribution, thank you.&lt;/P&gt;
&lt;P&gt;Gick&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 06:25:52 GMT</pubDate>
    <dc:creator>Gick</dc:creator>
    <dc:date>2022-04-28T06:25:52Z</dc:date>
    <item>
      <title>Automate the length of multiple character variables in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810301#M319545</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have several character variables of length 3, 5 , 13 or 90. I would like to define a&amp;nbsp; length of 70 for all the variables.&lt;/P&gt;
&lt;P&gt;Since I have several character variables (minus 120), I cannot change the length of each variable one by one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to automate this data step, can someone help me please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;BR /&gt;Gick&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 05:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810301#M319545</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2022-04-28T05:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Automate the length of multiple character variables in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810309#M319546</link>
      <description>&lt;P&gt;I would fix the length-statement in the step creating the dataset. BUT why do you need to have the same length?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 06:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810309#M319546</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-04-28T06:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Automate the length of multiple character variables in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810311#M319547</link>
      <description>&lt;P&gt;Because I want to apply a program that retrieves the name of the variable_name of the modality. For example male_sex. But it turns out that some variables have length 3, so doing so cuts off the name of the new modality.&lt;/P&gt;
&lt;P&gt;For example the sex variable has a length of 7, by applying my program I find sex_ho.&lt;BR /&gt;Image that I have a variable of length 3 but its name has 5 characters, with my program it will not take its modalities.&lt;/P&gt;
&lt;P&gt;For example: sales of yes/no modalities, the result will be sal instead of sales_oui.&lt;/P&gt;
&lt;P&gt;Reason for which, I wish to define a maximum length of 70 like that, all my program will give me the result which I seek.&lt;/P&gt;
&lt;P&gt;Waiting for your contribution, thank you.&lt;/P&gt;
&lt;P&gt;Gick&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 06:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810311#M319547</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2022-04-28T06:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Automate the length of multiple character variables in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810313#M319549</link>
      <description>&lt;P&gt;Sorry, but i can't follow your explanation. I would be easier, if you could post data in usable form and&amp;nbsp; show what you want to achieve using that example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using sashelp.class:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Clone sashelp.class */
data work.class;
   set sashelp.class;
run;

/* Get char vars and use call execute to apply the fix */
data strings;
   set sashelp.vcolumn(where= (Libname = 'WORK' and MemName = 'CLASS' and upcase(Type) = 'CHAR')) end=jobDone;
   
   if _n_ = 1 then do;
      call execute('proc sql noprint;');
      call execute('alter table work.class modify');
   end;
   
   call execute(catx(' ', Name, 'char(70)', ifc(not jobDone, ',', '')));
   
   if jobDone then do;
      call execute('; quit;');
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Apr 2022 06:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-the-length-of-multiple-character-variables-in-a-dataset/m-p/810313#M319549</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-04-28T06:55:20Z</dc:date>
    </item>
  </channel>
</rss>

