<?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: variable names disappearing after exporting to Excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706771#M216966</link>
    <description>&lt;P&gt;Thank you for linking the resource, but I think I'm still not sure how to solve my problem.&amp;nbsp; Can you assist me in how this would look for my import?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a little more context in what I'm trying to do, this spreadsheet with all these variables is downloaded from a survey website.&amp;nbsp; It is all the survey responses beginning with the very first response.&amp;nbsp; I have little to no control over how this spreadsheet is downloaded from the website, but this data is downloaded multiple times a day due to the high usage of this survey.&amp;nbsp; I then need to take this spreadsheet, import it into SAS, restructure the data so that I can take my dataset from short and wide to long and 'thin'.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we only had about 3500 variables, my current process was as follows:&lt;/P&gt;&lt;P&gt;1 - download the csv from the survey website&lt;/P&gt;&lt;P&gt;2 - import it into SAS&lt;/P&gt;&lt;P&gt;3 - rename variables and create a few new ones&lt;/P&gt;&lt;P&gt;4 - output into csv again&lt;/P&gt;&lt;P&gt;5 - re-import back into SAS with an infile statement forcing the formats of all these variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The advantage to doing it this way is that if a survey respondent doesn't fill out some information in a cell, for ex: a date of birth, I can then force that cell to be a date format instead of a blank character.&amp;nbsp; I need this because if I set these variables together and if their formats aren't the same, I get issues.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we only had about 3500 variables, this process worked just fine.&amp;nbsp; Now that we've had to add some options (thus adding on a lot more columns) to about 4200 variables, this process is no longer working for me because my variable titles are disappearing in Step 4.&amp;nbsp; This then hinders Step 5 and all the other SAS tasks that I need to do to work with this data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cassie&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2020 19:45:10 GMT</pubDate>
    <dc:creator>Cassie-Andra</dc:creator>
    <dc:date>2020-12-17T19:45:10Z</dc:date>
    <item>
      <title>variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706753#M216950</link>
      <description>&lt;P&gt;I have a SAS dataset containing 4203 variables that I'm trying to export to excel in a csv format. It exports without any issue, but when I open the csv file, it just drops the column names after about 1200 of those variables.&amp;nbsp; What is odd is that the data is still in the tables, but the variable/columns names are now blank.&amp;nbsp; I know that the length of the variable names is not the issue because the remaining variable names are named with the same naming convention as the first 1200 that did output with their column names.&amp;nbsp; Any ideas on why this is happening and how to include the variable names for the entire dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my SAS code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let Schooldata=[location];&lt;/P&gt;&lt;P&gt;proc export data=tempfile&lt;BR /&gt;outfile="&amp;amp;Schooldata\HOLD\School survey.csv"&lt;BR /&gt;dbms=csv label replace;&lt;BR /&gt;putnames=yes;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 19:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706753#M216950</guid>
      <dc:creator>Cassie-Andra</dc:creator>
      <dc:date>2020-12-17T19:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706757#M216953</link>
      <description>&lt;P&gt;What version of Excel?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's start with a few simple diagnostics: did you look at the CSV file with a text editor to make sure the csv file has the proper variable names, and the CSV file appears intact and whole and doesn't have problems? Are there ERRORs, WARNINGs or NOTEs in the SAS log for PROC EXPORT that indicate a problem? In Excel, if you click on a cell where the name should be, what is in there, and can you scroll up within that cell to find the name?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 19:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706757#M216953</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-17T19:12:17Z</dc:date>
    </item>
    <item>
      <title>After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706758#M216979</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import a csv file with over 4200 variable names.&amp;nbsp; For some reason, after I import this csv file into SAS, over a thousand of the variable names are now changed to VAR[#] followed by their order number.&amp;nbsp; So instead of having all of the variable names to work with, I have over a thousand variables named VAR3037 - VAR4203.&amp;nbsp; Help!&amp;nbsp; How can I keep all these variable names that are in my csv file?&amp;nbsp; I'm trying to pull in the very first row in the csv file as the column names, but the data doesn't actually start until row 4.&amp;nbsp; Rows 2 and 3 contain the descriptions of the variables (and those descriptions can be rather line....if that matters).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my SAS code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let Schooldata=[location];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Importing the csv file 'School Survey' */&lt;BR /&gt;proc import datafile="&amp;amp;Schooldata\School Survey.csv"&lt;BR /&gt;out=tempfile1&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;datarow=4;&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 19:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706758#M216979</guid>
      <dc:creator>Cassie-Andra</dc:creator>
      <dc:date>2020-12-17T19:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706764#M216981</link>
      <description>&lt;P&gt;Can someone merge this with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361227"&gt;@Cassie-Andra&lt;/a&gt;'s other similar thread?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 19:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706764#M216981</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-17T19:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706766#M216961</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361227"&gt;@Cassie-Andra&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a SAS dataset containing 4203 variables that I'm trying to export to excel in a csv format. It exports without any issue, but when I open the csv file, it just drops the column names after about 1200 of those variables.&amp;nbsp; What is odd is that the data is still in the tables, but the variable/columns names are now blank.&amp;nbsp; I know that the length of the variable names is not the issue because the remaining variable names are named with the same naming convention as the first 1200 that did output with their column names.&amp;nbsp; Any ideas on why this is happening and how to include the variable names for the entire dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my SAS code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let Schooldata=[location];&lt;/P&gt;
&lt;P&gt;proc export data=tempfile&lt;BR /&gt;outfile="&amp;amp;Schooldata\HOLD\School survey.csv"&lt;BR /&gt;dbms=csv label replace;&lt;BR /&gt;putnames=yes;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For heavens sake, why to you have 4200 variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you running into an LRECL related issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Related:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/td-p/655586" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/td-p/655586&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 19:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706766#M216961</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-17T19:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706767#M216962</link>
      <description>&lt;P&gt;Thank you for the response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm currently working with MS Excel for Office 365 MSO 32-bit.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did not look at the CSV file with a text editor.&amp;nbsp; I will have to research how to do that, but will take any recommendations.&amp;nbsp; I was able to confirm that the first ~1200 variables with names were correct.&amp;nbsp; The data seemed to be just fine.&amp;nbsp; The only issue was missing column names.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clicking on the cells didn't show anything, and there were no Errors or Warnings in the log but there was one NOTE I was curious about; it mentioned DROPOVER.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;NOTE: 3056 records were written to the file '[location] School survey.csv'.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;The minimum record length was 4431.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;The maximum record length was 32767.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;NOTE: Some output data was ignored because the DROPOVER option was specified.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;NOTE: There were 3055 observations read from the data set WORK.TEMPFILE.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 19:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706767#M216962</guid>
      <dc:creator>Cassie-Andra</dc:creator>
      <dc:date>2020-12-17T19:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706771#M216966</link>
      <description>&lt;P&gt;Thank you for linking the resource, but I think I'm still not sure how to solve my problem.&amp;nbsp; Can you assist me in how this would look for my import?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a little more context in what I'm trying to do, this spreadsheet with all these variables is downloaded from a survey website.&amp;nbsp; It is all the survey responses beginning with the very first response.&amp;nbsp; I have little to no control over how this spreadsheet is downloaded from the website, but this data is downloaded multiple times a day due to the high usage of this survey.&amp;nbsp; I then need to take this spreadsheet, import it into SAS, restructure the data so that I can take my dataset from short and wide to long and 'thin'.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we only had about 3500 variables, my current process was as follows:&lt;/P&gt;&lt;P&gt;1 - download the csv from the survey website&lt;/P&gt;&lt;P&gt;2 - import it into SAS&lt;/P&gt;&lt;P&gt;3 - rename variables and create a few new ones&lt;/P&gt;&lt;P&gt;4 - output into csv again&lt;/P&gt;&lt;P&gt;5 - re-import back into SAS with an infile statement forcing the formats of all these variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The advantage to doing it this way is that if a survey respondent doesn't fill out some information in a cell, for ex: a date of birth, I can then force that cell to be a date format instead of a blank character.&amp;nbsp; I need this because if I set these variables together and if their formats aren't the same, I get issues.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we only had about 3500 variables, this process worked just fine.&amp;nbsp; Now that we've had to add some options (thus adding on a lot more columns) to about 4200 variables, this process is no longer working for me because my variable titles are disappearing in Step 4.&amp;nbsp; This then hinders Step 5 and all the other SAS tasks that I need to do to work with this data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cassie&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 19:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706771#M216966</guid>
      <dc:creator>Cassie-Andra</dc:creator>
      <dc:date>2020-12-17T19:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706775#M216982</link>
      <description>&lt;P&gt;If you are &lt;STRONG&gt;IMPORTING &lt;/STRONG&gt; the CSV file that you said in this post &lt;A href="https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706753" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706753&lt;/A&gt; had "disappearing" variables names when&amp;nbsp;&lt;STRONG&gt;exported&lt;/STRONG&gt; then what you get is the expected result for columns that do not have any column heading. This seems very likely considering in the export you used:&lt;/P&gt;
&lt;PRE&gt;outfile="&amp;amp;Schooldata\HOLD\School survey.csv"&lt;/PRE&gt;
&lt;P&gt;and here you use:&lt;/P&gt;
&lt;PRE&gt; import datafile="&amp;amp;Schooldata\School Survey.csv"&lt;/PRE&gt;
&lt;P&gt;If at some time you had a CSV file that you imported into SAS and then exported with the same name and REPLACE option, as shown in your Export code, then congratulations, you destroyed your original data and need to find a backup that still has the original column headings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another common cause of VARxx naming is if the column headings are identical for the first 32 characters then the following columns with the same start will get VARxx names because there is no way for the procedure to "guess" what variable name to use when you exceed the number of&amp;nbsp; characters that SAS will use for a variable.&lt;/P&gt;
&lt;P&gt;If the length is less than 32 characters with duplicate names SAS will use suffixes for the following columns. I have had as many as 30 "total" columns some data source data. Proc Import turned those into Total, Total1, Total2, ...., Total30.&lt;/P&gt;
&lt;P&gt;Proc import will not create two variables with the same name. Period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 20:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706775#M216982</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-17T20:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706778#M216971</link>
      <description>Rather than a PROC EXPORT try a data step export where you're manually specifying the LRECL for one - I suspect you're running into lines that are larger than 32K characters most likely. I think you can get around that in a data step. I'm not sure why you can't build your conversion into #5 from a SAS data set rather than a re-import.....but that's a design issue.</description>
      <pubDate>Thu, 17 Dec 2020 20:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706778#M216971</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-17T20:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706782#M216983</link>
      <description>&lt;P&gt;First of all, great eye for detail in cross referencing both my posts.&amp;nbsp; To make my code seem a bit 'cleaner', I took off some of my output name, but they are definitely named differently.&amp;nbsp; Here is more of my code (minus about 10000 lines in the datastep):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let Schooldata=Location;&lt;BR /&gt;/* Importing the csv file 'School Survey' */&lt;BR /&gt;proc import datafile="&amp;amp;Schooldata\School Survey.csv"&lt;BR /&gt;out=tempfile1&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;datarow=4;&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/* Renaming the data variables and dropping unnecessary variables. */&lt;BR /&gt;data tempfile;&lt;BR /&gt;retain Recorded_Date Recorded_Time;&lt;BR /&gt;length Recorded_Date Recorded_Time 8;&lt;BR /&gt;set tempfile1;&lt;BR /&gt;Recorded_Date=datepart(recordeddate);&lt;BR /&gt;Recorded_Time=timepart(recordedtime);&lt;BR /&gt;format Recorded_Date mmddyy10. Recorded_Time time8.;&lt;BR /&gt;rename&lt;BR /&gt;Q3_4=Name&lt;BR /&gt;Q3_5=Address&lt;/P&gt;&lt;P&gt;.... (~4000 more variables);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc export data=tempfile&lt;BR /&gt;outfile="&amp;amp;Schooldata\HOLD\School survey temp.csv"&lt;BR /&gt;dbms=csv label replace;&lt;BR /&gt;putnames=yes;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data import_information;&lt;BR /&gt;infile "&amp;amp;Schooldata\HOLD\School survey temp.csv"&lt;BR /&gt;delimiter="," MISSOVER DSD lrecl=32767 firstobs=2 ;&lt;BR /&gt;length&lt;BR /&gt;Recorded_Date 8&lt;BR /&gt;Recorded_Time 8&lt;BR /&gt;Name $ 150&lt;BR /&gt;Address $ 200&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* creating permanent dataset */&lt;/P&gt;&lt;P&gt;libname school "&amp;amp;Schooldata";&lt;BR /&gt;data school.report;&lt;BR /&gt;set import_information;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great information about the column headings.&amp;nbsp; I verified again that the longest length of a title is 29 characters, and they are all distinct names.&amp;nbsp; We have a specific system we followed to name these variables, and they are all unique.&amp;nbsp; This code worked just fine up until we recently added about a 1000 new columns to capture more data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 20:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706782#M216983</guid>
      <dc:creator>Cassie-Andra</dc:creator>
      <dc:date>2020-12-17T20:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706783#M216975</link>
      <description>&lt;P&gt;Use a FILENAME with LRECL option for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename xout 'test.csv' lrecl=100000;
proc export file=xout data=sashelp.shoes dbms=csv  replace;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2020 20:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706783#M216975</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-12-17T20:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706784#M216984</link>
      <description>Do you really want that LABEL option in your EXPORT code? That prints out the labels not the variable names.</description>
      <pubDate>Thu, 17 Dec 2020 20:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706784#M216984</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-17T20:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706786#M216985</link>
      <description>&lt;P&gt;4200 variables to going to be a nightmare to work with, but perhaps the issue is that your header row is not in the first line?&amp;nbsp; Does the data itself start in row 4?&amp;nbsp; Where are the column headers?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also PROC IMPORT does not like header rows that are too long.&amp;nbsp; You could try defining a fileref so you could set a logical record length,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Schooldata=[location];
filename csv "&amp;amp;Schooldata\School Survey.csv" lrecl=1000000 ;
proc import datafile=csv dbms=csv
  out=tempfile1 replace
;
  datarow=4;
  guessingrows=max;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but I don't think it will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could read in the headers separately and rename the variables.&amp;nbsp; Use the GETNAMES='NO' statement in the PROC IMPORT.&amp;nbsp; Since you have a text file there is no need to use PROC IMPORT to read the headers.&amp;nbsp; So assuming the headers are in line 3 the code to read the headers might look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data headers;
  input "&amp;amp;Schooldata\School Survey.csv" dsd firstobs=3 obs=3 lrecl=1000000 ;
  length varnum 8 name $32 header $200 ;
  varnum+1;
&amp;nbsp;&amp;nbsp;input&amp;nbsp;header&amp;nbsp;:$200.&amp;nbsp;@@&amp;nbsp;;
  name = compress(header,' ');
run;   &amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then use those generated names to try to rename the VAR1, ... variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename rename temp;
data _null_;
  set headers end=eof;
  file rename lrecl=75;
  if _n_=1 then put 'rename ' @;
  put 'VAR' varnum '=' name @ ;
  if eof then put ';' ;
run;

proc datasets nolist lib=WORK ;
  modify tempfile1;
%include rename / source2;
   run;
quit;  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2020 20:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706786#M216985</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-17T20:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706788#M216987</link>
      <description>&lt;P&gt;FYI -&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361227"&gt;@Cassie-Andra&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; I've merged the threads into one now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 20:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706788#M216987</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-17T20:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706790#M216989</link>
      <description>&lt;P&gt;Where did you learn that&amp;nbsp;&lt;SPAN&gt;Q3_4=Name?&amp;nbsp; Do you have a dataset that describes the columns in the CSV file?&amp;nbsp; If so then use that data to generate the code to read the file instead of forcing SAS to GUESS how to read the file by using PROC IMPORT.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 20:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706790#M216989</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-17T20:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706807#M217000</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Rather than a PROC EXPORT try a data step export where you're manually specifying the LRECL for one - I suspect you're running into lines that are larger than 32K characters most likely. I think you can get around that in a data step. I'm not sure why you can't build your conversion into #5 from a SAS data set rather than a re-import.....but that's a design issue.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is starting with Proc Import for the same file format repeatedly, though apparently it changed.&lt;/P&gt;
&lt;P&gt;Time to let &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361227"&gt;@Cassie-Andra&lt;/a&gt; know that Proc Import writes a data step to the log when importing CSV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So copy the Data step from the log and paste into the editor. Make the changes there for the proper variable type by changing informats (or Attrib statements).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can read a different file by changing the infile statement and create a different output data set by changing the name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When changes are made you can add new informat information for the new variables and modify the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And since I saw the word "survey" you might investigate whether the Survey software will output files in SAS or SPSS files. I know of several packages that provide those options. Which can save you a ton of headaches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 21:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706807#M217000</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-17T21:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706827#M217014</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361227"&gt;@Cassie-Andra&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;... stuff deleted ...&lt;/P&gt;
&lt;P&gt;When we only had about 3500 variables, my current process was as follows:&lt;/P&gt;
&lt;P&gt;1 - download the csv from the survey website&lt;/P&gt;
&lt;P&gt;2 - import it into SAS&lt;/P&gt;
&lt;P&gt;3 - rename variables and create a few new ones&lt;/P&gt;
&lt;P&gt;4 - output into csv again&lt;/P&gt;
&lt;P&gt;5 - re-import back into SAS with an infile statement forcing the formats of all these variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The advantage to doing it this way is that if a survey respondent doesn't fill out some information in a cell, for ex: a date of birth, I can then force that cell to be a date format instead of a blank character.&amp;nbsp; I need this because if I set these variables together and if their formats aren't the same, I get issues.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your explanation appears to suggest that steps 4 and 5 are intended to do no more the change formats (or informats) of some variables.&amp;nbsp; If so, replace those steps with a single PROC DATASETS, which would allow you to change formats (and labels) in place.&amp;nbsp; No need to read/write the data - it just re-writes the header information in the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 22:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/706827#M217014</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-12-17T22:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: After importing data, variable names are changed to start with VAR followed by order number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/707520#M217243</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the sample code!&amp;nbsp; I've never seen this strategy before, but am thoroughly impressed.&amp;nbsp; I was actually able to solve my problem by importing with an infile statement instead of using proc import, but I think out of curiosity I'm going to try this method as well just to see how it works.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 16:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/707520#M217243</guid>
      <dc:creator>Cassie-Andra</dc:creator>
      <dc:date>2020-12-21T16:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: variable names disappearing after exporting to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/707522#M217245</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I once tried using an infile statement (a long while ago), and I can't recall at all why I abandoned that strategy and moved to proc import and proc export.&amp;nbsp; Your suggestion circled me back to trying it and it worked!!!&amp;nbsp; I used Excel's formulas and auto-fill to rename all the variables (they originally come in as a specific pattern of letters and numbers) and specify the lengths and formats I wanted, and then copied/pasted them over the appropriate sections in the import code.&amp;nbsp; That did the trick!!&amp;nbsp; No more guessing on which options I should choose in my statements.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, this particular survey platform does NOT offer SAS output files although eventually we will be migrating to a platform that does due to issues like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the reminder and giving me the inspiration to revise my process, which actually turned out to be a lot simpler than my original method.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 16:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-names-disappearing-after-exporting-to-Excel/m-p/707522#M217245</guid>
      <dc:creator>Cassie-Andra</dc:creator>
      <dc:date>2020-12-21T16:46:51Z</dc:date>
    </item>
  </channel>
</rss>

