<?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 Variable Naming Error when importing data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665146#M198823</link>
    <description>&lt;P&gt;I am using an existing SAS data set bdims.&amp;nbsp; When I import the data the variable names have a . separating multiple words rather than an _ which is used in the sample codes.&amp;nbsp; When I use the . name it does not recognize the variable.&lt;/P&gt;&lt;P&gt;EX:&amp;nbsp; Knee Diameter should be kne_di but it appears as kne.di&lt;/P&gt;&lt;P&gt;Using SAS on Demand for Academics&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jun 2020 20:09:21 GMT</pubDate>
    <dc:creator>3jyager</dc:creator>
    <dc:date>2020-06-25T20:09:21Z</dc:date>
    <item>
      <title>Variable Naming Error when importing data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665146#M198823</link>
      <description>&lt;P&gt;I am using an existing SAS data set bdims.&amp;nbsp; When I import the data the variable names have a . separating multiple words rather than an _ which is used in the sample codes.&amp;nbsp; When I use the . name it does not recognize the variable.&lt;/P&gt;&lt;P&gt;EX:&amp;nbsp; Knee Diameter should be kne_di but it appears as kne.di&lt;/P&gt;&lt;P&gt;Using SAS on Demand for Academics&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 20:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665146#M198823</guid>
      <dc:creator>3jyager</dc:creator>
      <dc:date>2020-06-25T20:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Naming Error when importing data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665149#M198826</link>
      <description>Show your log please.</description>
      <pubDate>Thu, 25 Jun 2020 20:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665149#M198826</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-25T20:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Naming Error when importing data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665151#M198828</link>
      <description>&lt;P&gt;Run proc contents on the data set.&lt;/P&gt;
&lt;P&gt;The text you see may be labels.&lt;/P&gt;
&lt;P&gt;If the data set was actually created with non-standard names then you need to set the system option validvarname=any. Which means that to reference to reference the variable name that you must use quotes and an "n" to use the variable in code: 'Some.poor.name'n for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am confused about 'import" though. You don't normally import an existing SAS data set, just use. If you actually ran some proc import code or similar you might show us what you did.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 20:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665151#M198828</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-25T20:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Naming Error when importing data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665161#M198832</link>
      <description>&lt;P&gt;Code is below:&lt;/P&gt;&lt;P&gt;filename bdims url '&lt;A href="http://www.openintro.org/stat/data/bdims.csv" target="_blank"&gt;http://www.openintro.org/stat/data/bdims.csv&lt;/A&gt;';&lt;BR /&gt;proc import datafile=bdims&lt;BR /&gt;out=bdims&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 20:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665161#M198832</guid>
      <dc:creator>3jyager</dc:creator>
      <dc:date>2020-06-25T20:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Naming Error when importing data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665165#M198835</link>
      <description>&lt;P&gt;Try adding this line before importing the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options validvarname=V7;&lt;/PRE&gt;
&lt;P&gt;if you want variables with _ instead of dots.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't use the On Demand but it seems that it may be defaulting to Validvarname=any which creates the names with dots. The V7 will enforce the rules for standard SAS variable names which would mean _ in the name.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 21:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665165#M198835</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-25T21:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Naming Error when importing data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665168#M198837</link>
      <description>&lt;P&gt;So you don't have a dataset. You have CSV file.&amp;nbsp; If you have the VALIDVARNAME option set to V7 then PROC IMPORT will generate valid SAS names from the header row in the CSV file.&amp;nbsp; But if you have VALIDVARNAME set to ANY then it won't. Instead it will just use the column header as if it was intended to be a variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So either change the option BEFORE the PROC IMPORT step, or get used to using name literals.&lt;/P&gt;
&lt;P&gt;For example to reference the first variable in TEST2 in this the example below you would need to use 'COL 1'n.&amp;nbsp; But to reference the first variable in TEST1 you could use COL_1 or 'COL_1'n.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
data _null_;
 file csv ;
 put 'Col 1,Col 2' / '1,2' / '2,3' ;
run;
options validvarname=v7;
proc import datafile=csv dbms=csv out=test1 replace; run;
options validvarname=any ;
proc import datafile=csv dbms=csv out=test2 replace; run;

proc contents data=test1 noprint out=test1_cont; run;
proc contents data=test2 noprint out=test2_cont; run;

proc compare data=test1_cont compare=test2_cont ;
  var name label;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;The COMPARE Procedure
Comparison of WORK.TEST1_CONT with WORK.TEST2_CONT
(Method=EXACT)

Variables with Unequal Values

Variable  Type  Len   Label          Ndif   MaxDif

NAME      CHAR   32   Variable Name     2



Value Comparison Results for Variables

__________________________________________________________
           ||  Variable Name
           ||  Base Value           Compare Value
       Obs ||  NAME                  NAME
 ________  ||  ___________________+  ___________________+
           ||
        1  ||  Col_1                 Col 1
        2  ||  Col_2                 Col 2
__________________________________________________________
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 21:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665168#M198837</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-25T21:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Naming Error when importing data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665169#M198838</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335369"&gt;@3jyager&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am using an existing SAS data set bdims.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code shown is importing a CSV from a website, not a SAS data set. The code creates a SAS data set based on the CSV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;When I import the data the variable names have a . separating multiple words rather than an _ which is used in the sample codes.&amp;nbsp; When I use the . name it does not recognize the variable.&lt;/BLOCKQUOTE&gt;
&lt;P&gt;These variables can be referred to using a slightly different notation, use quotes around the variable name and an N at the end. This is known as a name literal notation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_data = 'knee.di'n * 4;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Periods are valid in other variable names in other languages, but not in SAS. To avoid the issue as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; indicated by changing the SAS option to not allow variable names in that style.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option validvarname=v7;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then it will automatically convert all your variable names to appropriate easily referenced SAS data names, when you import the data.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 21:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Naming-Error-when-importing-data-sets/m-p/665169#M198838</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-25T21:26:39Z</dc:date>
    </item>
  </channel>
</rss>

