<?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: Names of variables that are written with periods (.) are replaced by hyphens (_). in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896892#M354410</link>
    <description>/*These are the real names of the variables and I have several like that.&lt;BR /&gt;Here is the data extract*/&lt;BR /&gt;data BDD_recod;&lt;BR /&gt;  input Nom $ sexe $ "2 a 3"n classe_age $ Pond organe "10 à 25 ans"n "Q30.A"n $ "Q35bis.A"n $ Q4_91;&lt;BR /&gt;  datalines;&lt;BR /&gt;Jean Masculin 1 0-4ans 10572.50 21 0 f g 1&lt;BR /&gt;Marie Feminin 0 5-14ans 10572.50 2 . i k 1&lt;BR /&gt;Pierre Masculin 1 15-24ans 10572.5 0 . K S 0&lt;BR /&gt;J Feminin 0 0-4ans 10572.50 7 1 E es 0&lt;BR /&gt;M Feminin 0 5-14ans 10572.50 6 1 df cit 9&lt;BR /&gt;Pe Masculin 0 0-4ans 10572.50 90 1 cdf cd 8 &lt;BR /&gt;Je Masculin 1 15-24ans 10572.50 32 1 df cd 7&lt;BR /&gt;Ma Masculin 1 0-4ans 10572.50 2 0 qh cre cd 4&lt;BR /&gt;Pire Feminin . 25-30ans 10572.5 10 1 sx cio 2&lt;BR /&gt;Mfir Feminin 0 35-40ans 10572.50 2.1 0 x vt 1&lt;BR /&gt;Pell Masculin . 40-45ans 10572.50 4.53 1 nb vr 10&lt;BR /&gt;Jeurs Masculin 0 15-24ans 10572.50 8 0 ij c 11&lt;BR /&gt;Mam Masculin 1 0-4ans 10572.50 56 1 jor b 12&lt;BR /&gt;Piress Feminin 1 15-24ans 10572.5 21.30 0 fr a 14&lt;BR /&gt;;</description>
    <pubDate>Tue, 03 Oct 2023 10:09:39 GMT</pubDate>
    <dc:creator>Gick</dc:creator>
    <dc:date>2023-10-03T10:09:39Z</dc:date>
    <item>
      <title>Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896878#M354402</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TableSAS.PNG" style="width: 960px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88513iAE4224CC509D33B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="TableSAS.PNG" alt="TableSAS.PNG" /&gt;&lt;/span&gt;Hi,&lt;/P&gt;
&lt;P&gt;Here is an extract from my SAS table. I want the names of variables that are written with periods (.) to be replaced by hyphens (_).&lt;/P&gt;
&lt;P&gt;Can someone help me please.&lt;/P&gt;
&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;
&lt;P&gt;Gick&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 09:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896878#M354402</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2023-10-03T09:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896879#M354403</link>
      <description>&lt;P&gt;First step:&amp;nbsp; run a PROC CONTENTS on the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will verify whether the names that you are looking at are actual variable names, rather than variable labels.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 09:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896879#M354403</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-10-03T09:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896892#M354410</link>
      <description>/*These are the real names of the variables and I have several like that.&lt;BR /&gt;Here is the data extract*/&lt;BR /&gt;data BDD_recod;&lt;BR /&gt;  input Nom $ sexe $ "2 a 3"n classe_age $ Pond organe "10 à 25 ans"n "Q30.A"n $ "Q35bis.A"n $ Q4_91;&lt;BR /&gt;  datalines;&lt;BR /&gt;Jean Masculin 1 0-4ans 10572.50 21 0 f g 1&lt;BR /&gt;Marie Feminin 0 5-14ans 10572.50 2 . i k 1&lt;BR /&gt;Pierre Masculin 1 15-24ans 10572.5 0 . K S 0&lt;BR /&gt;J Feminin 0 0-4ans 10572.50 7 1 E es 0&lt;BR /&gt;M Feminin 0 5-14ans 10572.50 6 1 df cit 9&lt;BR /&gt;Pe Masculin 0 0-4ans 10572.50 90 1 cdf cd 8 &lt;BR /&gt;Je Masculin 1 15-24ans 10572.50 32 1 df cd 7&lt;BR /&gt;Ma Masculin 1 0-4ans 10572.50 2 0 qh cre cd 4&lt;BR /&gt;Pire Feminin . 25-30ans 10572.5 10 1 sx cio 2&lt;BR /&gt;Mfir Feminin 0 35-40ans 10572.50 2.1 0 x vt 1&lt;BR /&gt;Pell Masculin . 40-45ans 10572.50 4.53 1 nb vr 10&lt;BR /&gt;Jeurs Masculin 0 15-24ans 10572.50 8 0 ij c 11&lt;BR /&gt;Mam Masculin 1 0-4ans 10572.50 56 1 jor b 12&lt;BR /&gt;Piress Feminin 1 15-24ans 10572.5 21.30 0 fr a 14&lt;BR /&gt;;</description>
      <pubDate>Tue, 03 Oct 2023 10:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896892#M354410</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2023-10-03T10:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896895#M354411</link>
      <description>This database is created manually. The real base sent to me is as presented in the image with several variables written with dots (.)</description>
      <pubDate>Tue, 03 Oct 2023 10:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896895#M354411</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2023-10-03T10:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896899#M354412</link>
      <description>Here is the message I get "ERROR: Variable Q35bis not found. ERROR: Variable A not found." because SAS does not recognize Q35bis variables. This is why I want to transform these variables with point(.) by (_), that is to say Q35bis.A becomes Q35bis_A. In fact SAS separates these variables into 2.&lt;BR /&gt;&lt;BR /&gt;  proc sql;&lt;BR /&gt;    select name into :var_list separated by ' '&lt;BR /&gt;    from dictionary.columns&lt;BR /&gt;    where libname = "WORK" and memname = "upcase(BDD_FINALE_POND)" and &lt;BR /&gt;          not prxmatch('/^\d/', name); &lt;BR /&gt;  quit;&lt;BR /&gt;  &lt;BR /&gt;%put &amp;amp;var_list.; &lt;BR /&gt;&lt;BR /&gt;%macro compare_freq_means(data=, weight_var=);&lt;BR /&gt;&lt;BR /&gt;  &lt;BR /&gt;  %do i = 1 %to %sysfunc(countw(&amp;amp;var_list.));&lt;BR /&gt;    %let current_var = %scan(&amp;amp;var_list., &amp;amp;i.);&lt;BR /&gt;&lt;BR /&gt;   &lt;BR /&gt;    %let var_type = %sysfunc(vartype(&amp;amp;data., &amp;amp;current_var.));&lt;BR /&gt;    %put var_type=&amp;amp;var_type.;&lt;BR /&gt;&lt;BR /&gt;    &lt;BR /&gt;    %if &amp;amp;var_type. = 2 %then %do;&lt;BR /&gt;      proc freq data=&amp;amp;data.;&lt;BR /&gt;        tables &amp;amp;current_var.;&lt;BR /&gt;        title "Résultats pour &amp;amp;current_var. sans pondération";&lt;BR /&gt;      run;&lt;BR /&gt;    %end;&lt;BR /&gt;    &lt;BR /&gt;    %else %do;&lt;BR /&gt;      proc means data=&amp;amp;data.;&lt;BR /&gt;        var &amp;amp;current_var.;&lt;BR /&gt;        title "Résultats pour &amp;amp;current_var. sans pondération";&lt;BR /&gt;      run;&lt;BR /&gt;    %end;&lt;BR /&gt;&lt;BR /&gt;    &lt;BR /&gt;    %if &amp;amp;var_type. = 2 %then %do;&lt;BR /&gt;      proc freq data=&amp;amp;data.;&lt;BR /&gt;        tables &amp;amp;current_var.;&lt;BR /&gt;        weight &amp;amp;weight_var.;&lt;BR /&gt;        title "Résultats pour &amp;amp;current_var. avec pondération";&lt;BR /&gt;      run;&lt;BR /&gt;    %end;&lt;BR /&gt;    %else %do;&lt;BR /&gt;      proc means data=&amp;amp;data.;&lt;BR /&gt;        var &amp;amp;current_var.;&lt;BR /&gt;        weight &amp;amp;weight_var.;&lt;BR /&gt;        title "Résultats pour &amp;amp;current_var. avec pondération";&lt;BR /&gt;      run;&lt;BR /&gt;    %end;&lt;BR /&gt;  %end;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%compare_freq_means(data=BDD_recod, weight_var=Pond);</description>
      <pubDate>Tue, 03 Oct 2023 10:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896899#M354412</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2023-10-03T10:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896905#M354417</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416124"&gt;@Gick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As requested above by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;, show us the PROC CONTENTS on this SAS data set.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 10:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896905#M354417</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-03T10:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896908#M354420</link>
      <description>&lt;P&gt;Funny strings like that should never (as in&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;NEVER&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;) be variable names, such stuff belongs in labels. Name literals (especially extremely stupid name literals like that) make your work unnecessarily hard.&lt;/P&gt;
&lt;P&gt;We programmers have a technical term for people who make their work deliberately and unnecessarily hard. We call them "idiots".&lt;/P&gt;
&lt;P&gt;What is your real data source? I've never seen a real DBA (database administrator) who would have crazy stuff like this as column names. So I guess you get some noob's Excel file. If you import that with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=v7;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you get easy-to-handle variable names OOTB, and the nice strings are automatically used as labels IIRC.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 11:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896908#M354420</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-03T11:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896926#M354431</link>
      <description>&lt;P&gt;I do not see any VARIABLE NAMES "written with a period" in that picture. I see some VALUES.&lt;/P&gt;
&lt;P&gt;If you mean to display the value of Q4_91 that currently shows as . where Nom='Ma' then change your system option for missing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options missing='_';&lt;/PRE&gt;
&lt;P&gt;That will change the SAS default behavior of showing &lt;STRONG&gt;missing values&lt;/STRONG&gt; from . to _ ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416124"&gt;@Gick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TableSAS.PNG" style="width: 960px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88513iAE4224CC509D33B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="TableSAS.PNG" alt="TableSAS.PNG" /&gt;&lt;/span&gt;Hi,&lt;/P&gt;
&lt;P&gt;Here is an extract from my SAS table. I want the names of variables that are written with periods (.) to be replaced by hyphens (_).&lt;/P&gt;
&lt;P&gt;Can someone help me please.&lt;/P&gt;
&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;
&lt;P&gt;Gick&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 12:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896926#M354431</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-03T12:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896936#M354439</link>
      <description>&lt;P&gt;You can use the RENAME option to rename the variables, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any ;

data have ;
 "Q30.a"n=1 ;
run ;

data want ;
  set have (rename=("Q30.a"n=Q30_a));
run ;

options validvarname=v7 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have a lot of problematic variable names, you can use additional code to generate the list of rename pairs.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 13:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896936#M354439</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-10-03T13:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896938#M354441</link>
      <description>&lt;P&gt;Renaming the variables is a good idea so you won't have to keep typing the difficult-to-type variable names. Adding labels is also a good thing to do in this situation if you absolutely have to maintain these difficult to type names for output legibility. I would do it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets library=work nolist;
    modify bdd_recod;
    rename "Q30.a"n=Q30_a;
    label q30_a='Q30.a';
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Oct 2023 13:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896938#M354441</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-03T13:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896948#M354445</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416124"&gt;@Gick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;This database is created manually. The real base sent to me is as presented in the image with several variables written with dots (.)&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;At least you aren't saying variable names with dots.&lt;/P&gt;
&lt;P&gt;That is a SAS system option. The default is to display MISSING values as a dot. You can control what character is displayed using the system option MISSING=. Pick any character. You can make a missing value appear as any single ASCII or EBCDIC (IBM Mainframe) your system supports.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check on the setting by running this code:&lt;/P&gt;
&lt;PRE&gt;proc options option=missing;run;&lt;/PRE&gt;
&lt;P&gt;Almost certainly your LOG will show something similar to the following: (your SAS version and line numbers likely to differ)&lt;/P&gt;
&lt;P&gt;To change that behavior regardless of who built the data set, who sent it or what ever you use the OPTIONS statement to set the appearance YOU want for MISSING values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is an actual useful feature. When the recipient of a report expects to see 0 then I use options missing='0'. There are times that a blank makes sense in context. Even had use for treating missing values as |. None of those affect the actual value stored in the data set.&lt;/P&gt;
&lt;PRE&gt;293  proc options option=missing;run;

    SAS (r) Proprietary Software Release 9.4  TS1M4

 MISSING=.         Specifies the character to print for missing numeric
                   values.
NOTE: PROCEDURE OPTIONS used (Total process time):

&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Oct 2023 14:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896948#M354445</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-03T14:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896956#M354451</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416124"&gt;@Gick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Here is the message I get "ERROR: Variable Q35bis not found. ERROR: Variable A not found." because SAS does not recognize Q35bis variables. This is why I want to transform these variables with point(.) by (_), that is to say Q35bis.A becomes Q35bis_A. In fact SAS separates these variables into 2.&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;nliteral(name)&lt;/STRONG&gt;&lt;/FONT&gt; into :var_list separated by &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;'|'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;from dictionary.columns&lt;BR /&gt;where libname = "WORK" and memname = "upcase(BDD_FINALE_POND)" and &lt;BR /&gt;not prxmatch('/^\d/', name); &lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;%put &amp;amp;var_list.; &lt;BR /&gt;&lt;BR /&gt;%macro compare_freq_means(data=, weight_var=);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;var_list&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;., |&lt;/STRONG&gt;&lt;/FONT&gt;));&amp;nbsp;&lt;BR /&gt;%let current_var = %scan(&amp;amp;var_list., &amp;amp;i.&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;, |&lt;/STRONG&gt;&lt;/FONT&gt;);&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you use the type of notation with periods and spaces you need to use NLITERAL function when selecting the names of the variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also want to change the separator to be a more defined character otherwise, I believe it's a space. And since you have spaces in your variable names this will have things show up as multiple words.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So add a delimiter to your variables and to the COUNTW and SCAN() functions as well&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What do you mean by the data set is created manually? If by data step as below, feel free to change it in the text directly.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*These are the real names of the variables and I have several like that.
Here is the data extract*/
data BDD_recod;
input Nom $ sexe $ _2_a_3 classe_age $ Pond organe _10_a_25 Q30_A $ Q35bis_A $ Q4_91;
datalines;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Oct 2023 15:10:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896956#M354451</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-10-03T15:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896979#M354460</link>
      <description>&lt;P&gt;So someone sent you a dataset with those strange variable names?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you just ask them to create valid variable names, since it is their data it should be easier for them to make the decisions about what names are appropriate.&amp;nbsp; They can use the LABEL to store the strange characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really must fix it then you should be able to just create a macro variable with OLD=NEW name pairs needed by the RENAME statement or the RENAME= dataset option.&amp;nbsp; You could store the original name into the label.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to replace multiple adjacent nonstandard characters with a single _ to make the resulting names easier to read and type.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=HAVE noprint out=contents;
run;

data names;
  set contents;
  newname=translate(trim(name),' ',compress(name,,'ad'));
  newname=translate(strip(compbl(newname)),'_',' ');
  if '0' &amp;lt;= char(newname,1) &amp;lt;='9' then newname='_'||newname;
  keep name newname;
run;  

proc sql noprint;
%let renames=;
%let labels=;
select catx('=',nliteral(name),newname)
     , catx('=',newname,quote(trim(name),"'"))
  into :renames separated by ' '
     , :labels separated by ' '
from names
where upcase(name) ne upcase(newname)
;
quit;

%put &amp;amp;=sqlobs ;
%put &amp;amp;=renames;
%put &amp;amp;=labels;

data want;
  set have(rename=(&amp;amp;renames));
  label &amp;amp;labels;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's make an example dataset and try it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;
data have;
  id=1;
  'q30.a'n=2;
  '123+-45&amp;amp;67'n=3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;70
71   %put &amp;amp;=sqlobs ;
SQLOBS=2
72   %put &amp;amp;=renames;
RENAMES='123+-45&amp;amp;67'N=_123_45_67 "q30.a"N=q30_a
73   %put &amp;amp;=labels;
LABELS=_123_45_67='123+-45&amp;amp;67' q30_a='q30.a'
74
75   data want;
76     set have(rename=(&amp;amp;renames));
77     label &amp;amp;labels;
78   run;

NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: The data set WORK.WANT has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds


79   proc contents varnum;
80   run;

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.05 seconds
      cpu time            0.03 seconds
&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1696351776575.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88533i9EC84414FE9990D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1696351776575.png" alt="Tom_0-1696351776575.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 16:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/896979#M354460</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-03T16:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/897101#M354503</link>
      <description>Hi,&lt;BR /&gt;Well, I don't know what to say. The SAS table that I proposed to you is made manually (I adapted it to the table that I actually have to clearly explain my concern) but in reality, my SAS data is provided as I sent you in the image.&lt;BR /&gt;&lt;BR /&gt;I have several variables like this.&lt;BR /&gt;&lt;BR /&gt;I know very well that no one will write these variable names like this. Which doesn't prevent me from being sent a SAS table like that. The idea is to try to see if anyone could offer me an approach.&lt;BR /&gt;&lt;BR /&gt;THANKS</description>
      <pubDate>Wed, 04 Oct 2023 06:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/897101#M354503</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2023-10-04T06:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/897102#M354504</link>
      <description>The code is perfect except that the "want" table created has no observations.&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;BR /&gt;Gick</description>
      <pubDate>Wed, 04 Oct 2023 06:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/897102#M354504</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2023-10-04T06:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/897103#M354505</link>
      <description>/*Here my proposition of code*/&lt;BR /&gt;&lt;BR /&gt;%macro remplacer_points(table_in, table_out);&lt;BR /&gt;    &lt;BR /&gt;    data &amp;amp;table_out;&lt;BR /&gt;        set &amp;amp;table_in;&lt;BR /&gt;&lt;BR /&gt;        &lt;BR /&gt;        array old_vars(*) _numeric_;&lt;BR /&gt;        array new_vars(*) $ _temporary_;&lt;BR /&gt;&lt;BR /&gt;        do i = 1 to dim(old_vars);&lt;BR /&gt;            /* Have Names variable */&lt;BR /&gt;            var_name = vname(old_vars[i]);&lt;BR /&gt;&lt;BR /&gt;            /* Remplace  (.) by  (_) */&lt;BR /&gt;            new_vars[i] = tranwrd(var_name, '.', '_');&lt;BR /&gt;        end;&lt;BR /&gt;&lt;BR /&gt;        &lt;BR /&gt;        do i = 1 to dim(old_vars);&lt;BR /&gt;            if not missing(new_vars[i]) then&lt;BR /&gt;                rename old_vars[i]=new_vars[i];&lt;BR /&gt;        end;&lt;BR /&gt;&lt;BR /&gt;        drop i var_name;&lt;BR /&gt;    run;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%remplacer_points(table_in=BDD_recod, table_out=BBB);</description>
      <pubDate>Wed, 04 Oct 2023 07:30:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/897103#M354505</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2023-10-04T07:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Names of variables that are written with periods (.) are replaced by hyphens (_).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/897104#M354506</link>
      <description>/*Another code*/&lt;BR /&gt;%macro remplacer_points(table_in, table_out);&lt;BR /&gt;    &lt;BR /&gt;    proc sql noprint;&lt;BR /&gt;        select name into :varlist separated by ' '&lt;BR /&gt;        from dictionary.columns&lt;BR /&gt;        where libname = upcase(libname) and memname = upcase("&amp;amp;table_in");&lt;BR /&gt;    quit;&lt;BR /&gt;&lt;BR /&gt;    &lt;BR /&gt;    data &amp;amp;table_out;&lt;BR /&gt;        set &amp;amp;table_in;&lt;BR /&gt;&lt;BR /&gt;        &lt;BR /&gt;        %let num_vars = %sysfunc(countw(&amp;amp;varlist));&lt;BR /&gt;        %do i = 1 %to &amp;amp;num_vars;&lt;BR /&gt;            /* Obtenir le nom de la variable */&lt;BR /&gt;            %let var_name = %scan(&amp;amp;varlist, &amp;amp;i);&lt;BR /&gt;			%put &amp;amp;var_name.;&lt;BR /&gt;&lt;BR /&gt;            &lt;BR /&gt;            %let new_var_name = %sysfunc(tranwrd(&amp;amp;var_name, '.', '_'));&lt;BR /&gt;			%put &amp;amp;new_var_name.;&lt;BR /&gt;&lt;BR /&gt;          &lt;BR /&gt;            rename &amp;amp;var_name = &amp;amp;new_var_name;&lt;BR /&gt;        %end;&lt;BR /&gt;    run;&lt;BR /&gt;%mend; Always the same</description>
      <pubDate>Wed, 04 Oct 2023 08:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-variables-that-are-written-with-periods-are-replaced-by/m-p/897104#M354506</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2023-10-04T08:19:14Z</dc:date>
    </item>
  </channel>
</rss>

