<?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: assigning different datatype to dataset variables during proc import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657561#M197053</link>
    <description>&lt;P&gt;How similar in structure are these files? This means column order with same intended values/types?&lt;/P&gt;
&lt;P&gt;How many header rows (a major bane of Proc Import)? Does this number change in files of the same "structure".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the files have a similar structure you might be able to use either LIBNAME PCFILES or EXCEL to access the data. Then you would have meta data information available available from the SASHELP.Vcolumns or Dictionary.Columns when using Proc SQL. Then write/ modify code to create new SAS datasets as needed, variable names, types, labels and such using data step code. But if you have lots of different layouts this can get cumbersome because you will have to have code that examines pretty much each column of the spreadsheet with the desired type and implement the correct code for conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The details are important though. If the column orders or numbers of header rows change then you can get into very complicated headaches in attempting to automate. I have one source of XLSX I have to deal with where the 1) column orders change from month to month, 2) the number of header rows can change from month to month and 3) the "values" of a file or personal identification value will change to DATE formats partway through the file. And I have no way I can think of that would "automate" that conversion with out testing every single value in every single column.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2020 15:12:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-06-11T15:12:25Z</dc:date>
    <item>
      <title>assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657237#M196969</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do proc import from Excel workbook to load some empty fields which will be later added with integer values. The dataset is guessing rows in a way that string datatype is assigned to these variables. Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Anjali&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 07:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657237#M196969</guid>
      <dc:creator>SASUserRocks</dc:creator>
      <dc:date>2020-06-11T07:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657262#M196972</link>
      <description>&lt;P&gt;Save the required sheet(s) to csv file(s), and read those with a data step where you have full control over the import process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 08:12:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657262#M196972</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-11T08:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657263#M196973</link>
      <description>&lt;P&gt;Please try to use the mixed=yes option to avoid the issue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT OUT= mydata
     DATAFILE= "J:\users\nsouli\Debugging.xls" 
     DBMS=EXCEL REPLACE;
     SHEET="'SAS$'"; 
     GETNAMES=YES;
     MIXED=yes;     
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jun 2020 08:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657263#M196973</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-11T08:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657264#M196974</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286518"&gt;@SASUserRocks&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try to convert your excel file in csv / txt. Then you can&amp;nbsp;use a DATA step to import your file and specify the type of your variables with the correct informat in an INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 08:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657264#M196974</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-11T08:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657334#M196982</link>
      <description>&lt;P&gt;There are huge number of xlsx files that I will receive everyday and not willing to create overhead at SAS server.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 08:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657334#M196982</guid>
      <dc:creator>SASUserRocks</dc:creator>
      <dc:date>2020-06-11T08:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657335#M196983</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&amp;nbsp;Tried below code and its throwing error "ERROR: DBMS type EXCEL not valid for import."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import replace datafile= "/SASAnalytics/DA/Daily_File_20200516.xlsx"&lt;BR /&gt;out= DAShare2.Test&lt;BR /&gt;dbms=excel ;&lt;BR /&gt;DBDSOPTS= "DBTYPE=(DSLV_personal_finance_UAENation='NUM(8)')";&lt;BR /&gt;MIXED=yes;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 08:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657335#M196983</guid>
      <dc:creator>SASUserRocks</dc:creator>
      <dc:date>2020-06-11T08:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657339#M196984</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; There are around 200 xlsx , I wont be able to manually convert them to csv.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 09:01:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657339#M196984</guid>
      <dc:creator>SASUserRocks</dc:creator>
      <dc:date>2020-06-11T09:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657375#M196986</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286518"&gt;@SASUserRocks&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; There are around 200 xlsx , I wont be able to manually convert them to csv.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Using the worst imaginable file format for mass data transfer is at best stupid. No matter what you do, you end up with manual conversions and/or fixes, because every single import will end up with more or less subtle differences.&lt;/P&gt;
&lt;P&gt;You might be able to automate a xlsx to csv conversion with LibreOffice or VBA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have the data sent in a sensible format in the first place.&lt;/P&gt;
&lt;P&gt;Excel is only good for manual tinkering, not for automatable (and&amp;nbsp;&lt;EM&gt;reliably&lt;/EM&gt; automatable) processes.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 09:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657375#M196986</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-11T09:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657445#M197003</link>
      <description>&lt;P&gt;Anjali,&lt;/P&gt;
&lt;P&gt;You keep mentioning large amount of excel files is it 100s, 1000s. I hope you do not process them manually. Unfortunately SAS has minimal control on reading data from excel as opposed to other formats. If you know what the fields are and what the formats should be you can do explicit conversion after reading it into a sas dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 11:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657445#M197003</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-11T11:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657517#M197031</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;&amp;nbsp; , Currently its 200, but this is daily incremental file that keeps coming till future date. I am trying below code to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;options validvarname=any;&lt;BR /&gt;%macro abc;&lt;BR /&gt;proc import replace datafile= "/SASAnalytics/DA/Weblog_Lemnisk/ProdData/NewSet/Daily_File_20200516.xlsx"&lt;BR /&gt;out=DAShare2.DSN_TEMP&lt;BR /&gt;DBMS=XLSX;&lt;/P&gt;&lt;P&gt;%let&amp;nbsp;varlist= cookie $20 date $10 timestamp $20 Last_url_visited $800 ip $20 stage $20 device $20 os $20 browser $20 Page $120 Product $120&lt;BR /&gt;SubProduct $120 Pname $120 cookieBirth $20 typnmarr $120 dslv 5 last_10_urls_visited $400 taxonomy $400 dsdo 20 clickid $120 DSLV_cards 20&lt;BR /&gt;DSLV_accounts 20 DSLV_loans 20 DSLV_personal_loan_expats 20 DSLV_bca_silver 20 DSLV_betaqti_credit_card 20 DSLV_etihad_GA_account 20&lt;BR /&gt;DSLV_credit_cards 20 DSLV_touchpoint_ic 20 DSLV_privilege_C_Plat_DC 20 DSLV_millionaire_D_Saving_Acc 20 DSLV_traveller_credit_card 20&lt;BR /&gt;DSLV_adcb_titanium_debit_card 20 DSLV_touchpoint_platinum_cc 20 DSLV_fixed_deposit_account 20 DSLV_active_saver_account 20 DSLV_excellence_plat_DC 20&lt;BR /&gt;DSLV_etihad_guest_Abo_Exce 20 DSLV_personal_loan_uaeNationl 20 DSLV_etihad_guest_Infin_CC 20 DSLV_personal_finance_for_expats 20&lt;BR /&gt;DSLV_personal_finance_UAENation 20 DSLV_etihad_guest_privilege_acc 20 DSLV_etihad_guest_excellency_acc 20 DSLV_etihad_platinum_credit_card 20&lt;BR /&gt;DSLV_etihad_guest_accounts 20;&lt;/P&gt;&lt;P&gt;data&amp;nbsp;dsn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;length&amp;nbsp;&amp;amp;varlist&amp;nbsp;;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;set&amp;nbsp;DAShare2.DSN_temp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;format _all_;&lt;BR /&gt;&amp;nbsp;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%abc;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 13:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657517#M197031</guid>
      <dc:creator>SASUserRocks</dc:creator>
      <dc:date>2020-06-11T13:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657524#M197034</link>
      <description>&lt;P&gt;First you can check if the formats of variable from the excel read is consistent with what you expect. If not then write out explicit conversions. 200 files is not that many, being xlsx i can guess at most a million rows, unless the number of sheets you read is more than 5. Can you request whoever is generating these files to write as csv?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 13:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657524#M197034</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-11T13:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657536#M197040</link>
      <description>&lt;P&gt;20 is not a valid length for numeric variables (maximum is 8). Your code will also not work if a column was imported with the wrong type (numeric vs. character).&lt;/P&gt;
&lt;P&gt;I can only repeat: from 20+ years of SAS experience, using Excel files for this is madness.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 14:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657536#M197040</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-11T14:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657549#M197047</link>
      <description>&lt;P&gt;Accept that fact. We will get files in CSV format in future , until then I have to process xlsx files for the dashboard.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 14:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657549#M197047</guid>
      <dc:creator>SASUserRocks</dc:creator>
      <dc:date>2020-06-11T14:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657561#M197053</link>
      <description>&lt;P&gt;How similar in structure are these files? This means column order with same intended values/types?&lt;/P&gt;
&lt;P&gt;How many header rows (a major bane of Proc Import)? Does this number change in files of the same "structure".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the files have a similar structure you might be able to use either LIBNAME PCFILES or EXCEL to access the data. Then you would have meta data information available available from the SASHELP.Vcolumns or Dictionary.Columns when using Proc SQL. Then write/ modify code to create new SAS datasets as needed, variable names, types, labels and such using data step code. But if you have lots of different layouts this can get cumbersome because you will have to have code that examines pretty much each column of the spreadsheet with the desired type and implement the correct code for conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The details are important though. If the column orders or numbers of header rows change then you can get into very complicated headaches in attempting to automate. I have one source of XLSX I have to deal with where the 1) column orders change from month to month, 2) the number of header rows can change from month to month and 3) the "values" of a file or personal identification value will change to DATE formats partway through the file. And I have no way I can think of that would "automate" that conversion with out testing every single value in every single column.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657561#M197053</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-11T15:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657570#M197060</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&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;Files are of similar structure and i tried using dbms= EXCEL which is not working and have reported to SAS&amp;nbsp; admin. In future i will get these files in csv,until then i have to live with xlsx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now am trying to do below code work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro abc;&lt;BR /&gt;proc options option=validvarname;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc import replace datafile= "/SASAnalytics/DA/Daily_File_20200516.xlsx"&lt;BR /&gt;out=DAShare2.DSN_TEMP&lt;BR /&gt;DBMS=XLSX;&lt;BR /&gt;%let&amp;nbsp;varlist= cookie $28 date $10 timestamp $28 Last_url_visited $800 ip $28 stage $28 device $28 os $28 browser $28 Page $28 Product $28&lt;BR /&gt;SubProduct $120 Pname $8 cookieBirth $8 typnmarr $28 dslv 5 last_10_urls_visited $400 taxonomy $400 dsdo 8 clickid $28 DSLV_cards 8&lt;BR /&gt;DSLV_accounts 8 DSLV_loans 8 DSLV_personal_loan_expats 8 DSLV_bca_silver 8 DSLV_betaqti_credit_card 8 DSLV_etihad_GA_account 8&lt;BR /&gt;DSLV_credit_cards 8 DSLV_touchpoint_ic 8 DSLV_privilege_C_Plat_DC 8 DSLV_millionaire_D_Saving_Acc 8 DSLV_traveller_credit_card 8&lt;BR /&gt;DSLV_adcb_titanium_debit_card 8 DSLV_touchpoint_platinum_cc 8 DSLV_fixed_deposit_account 8 DSLV_active_saver_account 8 DSLV_excellence_plat_DC 8&lt;BR /&gt;DSLV_etihad_guest_Abo_Exce 8 DSLV_personal_loan_uaeNationl 8 DSLV_etihad_guest_Infin_CC 8 DSLV_personal_finance_for_expats 8&lt;BR /&gt;DSLV_personal_finance_UAENation 8 DSLV_etihad_guest_privilege_acc 8 DSLV_etihad_guest_excellency_acc 8 DSLV_etihad_platinum_credit_card 8&lt;BR /&gt;DSLV_etihad_guest_accounts 8;&lt;BR /&gt;data&amp;nbsp;dsn;&lt;BR /&gt;length&amp;nbsp;&amp;amp;varlist&amp;nbsp;;&lt;BR /&gt;set&amp;nbsp;DAShare2.DSN_temp;&lt;BR /&gt;format _all_;&lt;BR /&gt;&amp;nbsp;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%abc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is throwing error :-&lt;BR /&gt;ERROR: The value 'LET&amp;nbsp;VARLIST'n is not a valid SAS name.&lt;BR /&gt;WARNING: Apparent invocation of macro LET&amp;nbsp;VARLIST not resolved.&lt;BR /&gt;180: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;NOTE: The previous statement has been deleted.&lt;BR /&gt;NOTE: The previous statement has been deleted.&lt;BR /&gt;ERROR: Symbolic variable name VARLIST&amp;nbsp; must contain only letters, digits, and underscores.&lt;BR /&gt;NOTE: The previous statement has been deleted.&lt;BR /&gt;NOTE: The previous statement has been deleted.&lt;BR /&gt;NOTE: The previous statement has been deleted.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657570#M197060</guid>
      <dc:creator>SASUserRocks</dc:creator>
      <dc:date>2020-06-11T15:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657575#M197064</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro abc;
proc options option=validvarname;
run;

proc import replace datafile= "/SASAnalytics/DA/Daily_File_20200516.xlsx"
out=DAShare2.DSN_TEMP
DBMS=XLSX;
run;
proc export data=NEW dbms=csv

outfile="temp.csv"

replace;

run;
%let varlist= cookie $28 date $10 timestamp $28 Last_url_visited $800 ip $28 stage $28 device $28 os $28 browser $28 Page $28 Product $28
SubProduct $120 Pname $8 cookieBirth $8 typnmarr $28 dslv 5 last_10_urls_visited $400 taxonomy $400 dsdo 8 clickid $28 DSLV_cards 8
DSLV_accounts 8 DSLV_loans 8 DSLV_personal_loan_expats 8 DSLV_bca_silver 8 DSLV_betaqti_credit_card 8 DSLV_etihad_GA_account 8
DSLV_credit_cards 8 DSLV_touchpoint_ic 8 DSLV_privilege_C_Plat_DC 8 DSLV_millionaire_D_Saving_Acc 8 DSLV_traveller_credit_card 8
DSLV_adcb_titanium_debit_card 8 DSLV_touchpoint_platinum_cc 8 DSLV_fixed_deposit_account 8 DSLV_active_saver_account 8 DSLV_excellence_plat_DC 8
DSLV_etihad_guest_Abo_Exce 8 DSLV_personal_loan_uaeNationl 8 DSLV_etihad_guest_Infin_CC 8 DSLV_personal_finance_for_expats 8
DSLV_personal_finance_UAENation 8 DSLV_etihad_guest_privilege_acc 8 DSLV_etihad_guest_excellency_acc 8 DSLV_etihad_platinum_credit_card 8
DSLV_etihad_guest_accounts 8;
data dsn;
informat &amp;lt;put your varlist here&amp;gt; ;
infile "test.csv" &amp;lt;options&amp;gt; ;
input &amp;lt;put your varlist here&amp;gt; ;
set DAShare2.DSN_temp;
 run;
%mend;
%abc;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657575#M197064</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-11T15:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657581#M197066</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro abc;
proc options option=validvarname;
run;

proc import replace datafile= "/SASAnalytics/DA/Daily_File_20200516.xlsx"
out=DAShare2.DSN_TEMP
DBMS=XLSX;
run;
proc export data=NEW dbms=csv

outfile="temp.csv"

replace;

run;
%let varlist= cookie $28 date $10 timestamp $28 Last_url_visited $800 ip $28 stage $28 device $28 os $28 browser $28 Page $28 Product $28
SubProduct $120 Pname $8 cookieBirth $8 typnmarr $28 dslv 5 last_10_urls_visited $400 taxonomy $400 dsdo 8 clickid $28 DSLV_cards 8
DSLV_accounts 8 DSLV_loans 8 DSLV_personal_loan_expats 8 DSLV_bca_silver 8 DSLV_betaqti_credit_card 8 DSLV_etihad_GA_account 8
DSLV_credit_cards 8 DSLV_touchpoint_ic 8 DSLV_privilege_C_Plat_DC 8 DSLV_millionaire_D_Saving_Acc 8 DSLV_traveller_credit_card 8
DSLV_adcb_titanium_debit_card 8 DSLV_touchpoint_platinum_cc 8 DSLV_fixed_deposit_account 8 DSLV_active_saver_account 8 DSLV_excellence_plat_DC 8
DSLV_etihad_guest_Abo_Exce 8 DSLV_personal_loan_uaeNationl 8 DSLV_etihad_guest_Infin_CC 8 DSLV_personal_finance_for_expats 8
DSLV_personal_finance_UAENation 8 DSLV_etihad_guest_privilege_acc 8 DSLV_etihad_guest_excellency_acc 8 DSLV_etihad_platinum_credit_card 8
DSLV_etihad_guest_accounts 8;
data dsn;
informat &amp;lt;put your varlist here&amp;gt; ;
infile "test.csv" &amp;lt;options&amp;gt; ;
input &amp;lt;put your varlist here&amp;gt; ;
set DAShare2.DSN_temp;
 run;
%mend;
%abc;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In an INFORMAT statement the format name must end with a period. So the VARLIST would need to be changed to work with INFORMAT.&lt;/P&gt;
&lt;P&gt;Similarly on an input statement if you want an informat applied you need the period. However you would not want that on the actual input statement, just the names of the variables. The Informat would be applied. So the code needs two macro variables, one with the informat for use on that statement and the other without for use on the Input statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the import/ export work properly I don't think you want to SET the data set created by Proc Import on the data step to read the csv.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657581#M197066</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-11T15:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657587#M197068</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;for pointing out about the set in the data step. That is indeed my oversight. Other than that I agree with what you said about informats and inputs. That is why I put it in angular brackets on the informat and input statements leaving it as an exercise for &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286518"&gt;@SASUserRocks&lt;/a&gt;. I am not sure about needing two macro variables if the list of variables and the order is consistent.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286518"&gt;@SASUserRocks&lt;/a&gt;&amp;nbsp; might as well hard code them&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 16:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657587#M197068</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-11T16:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657589#M197070</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;for pointing out about the set in the data step. That is indeed my oversight. Other than that I agree with what you said about informats and inputs. That is why I put it in angular brackets on the informat and input statements leaving it as an exercise for &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286518"&gt;@SASUserRocks&lt;/a&gt;. I am not sure about needing two macro variables if the list of variables and the order is consistent.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286518"&gt;@SASUserRocks&lt;/a&gt;&amp;nbsp; might as well hard code them&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You may want to test on a data set what happens when you indicate a format on the input statement with delimited data when the length of the values is less than the informat.&lt;/P&gt;
&lt;P&gt;The Input statement in effect will override a default informat set with an Informat or Attribute statement, which can do very bad things to delimited data.&lt;/P&gt;
&lt;P&gt;And the fix that would allow the informat on the Input statement would mean than an Informat statement was not needed.&lt;/P&gt;
&lt;P&gt;The comment was based on the&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt; &amp;lt;put your varlist here&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;in two places which can lead to improper use in at least one statement when coupled with the example varlist definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider these two data steps:&lt;/P&gt;
&lt;PRE&gt;data example;
   infile datalines dlm=',' truncover;
   informat x $5. y $6.;
   input x y;
datalines;
abc,def
abcde,fghijk
;

data example2;
   infile datalines dlm=',' truncover;
   informat x $5. y $6.;
   input x  $5. y $6.;
datalines;
abc,def
abcde,fghijk
;
&lt;/PRE&gt;
&lt;P&gt;And see which result you actually might want.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 16:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657589#M197070</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-11T16:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: assigning different datatype to dataset variables during proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657597#M197073</link>
      <description>&lt;P&gt;Close.&amp;nbsp; Try this instead.&amp;nbsp; Use PROC IMPORT to read it in. Use data step to write it out to temporary CSV file. Then use another data step to read in the data from the CSV file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The VALIDVARNAME=ANY doesn't really do you any good, none of the names you want to use require it. The length for numeric variables should be 8 since SAS stores them as 8 byte floating point numbers.&amp;nbsp; If you have any actual date, time or datetime values then you will want to add a FORMAT statement to the data step that creates the final dataset from the temporary csv file.&amp;nbsp; But you don't need to write formatted values to the temporary CSV file, so no need for any INFORMAT statements.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro abc(infile,dsn);
* Import sheet ;
proc import  dbms=xlsx out=_temp_ replace
  datafile="/SASAnalytics/DA/Weblog_Lemnisk/ProdData/NewSet/&amp;amp;infile..xlsx"
;
run;
* Write to CSV file ;
filename csv temp;
data _null_;
  file csv dsd ;
  set _temp_;
  put (_all_) (+0);
  format _numeric_ best32. _character_;
run;

* Read from CSV file ;
data &amp;amp;dsn;
  length
    cookie $20
    date $10
    timestamp $20
    Last_url_visited $800
    ip $20
    stage $20
    device $20
    os $20
    browser $20
    Page $120
    Product $120
    SubProduct $120
    Pname $120
    cookieBirth $20
    typnmarr $120
    dslv 8
    last_10_urls_visited $400
    taxonomy $400
    dsdo 8
    clickid $120
    DSLV_cards 8
    DSLV_accounts 8
    DSLV_loans 8
    DSLV_personal_loan_expats 8
    DSLV_bca_silver 8
    DSLV_betaqti_credit_card 8
    DSLV_etihad_GA_account 8
    DSLV_credit_cards 8
    DSLV_touchpoint_ic 8
    DSLV_privilege_C_Plat_DC 8
    DSLV_millionaire_D_Saving_Acc 8
    DSLV_traveller_credit_card 8
    DSLV_adcb_titanium_debit_card 8
    DSLV_touchpoint_platinum_cc 8
    DSLV_fixed_deposit_account 8
    DSLV_active_saver_account 8
    DSLV_excellence_plat_DC 8
    DSLV_etihad_guest_Abo_Exce 8
    DSLV_personal_loan_uaeNationl 8
    DSLV_etihad_guest_Infin_CC 8
    DSLV_personal_finance_for_expats 8
    DSLV_personal_finance_UAENation 8
    DSLV_etihad_guest_privilege_acc 8
    DSLV_etihad_guest_excellency_acc 8
    DSLV_etihad_platinum_credit_card 8
    DSLV_etihad_guest_accounts 8
  ;
  infile csv dsd truncover ;
  input (_all_) (+0);
 run;
%mend;

*options validvarname=any;
%abc(Daily_File_20200516,dsn1)
%abc(Daily_File_20200517,dsn2)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 17:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assigning-different-datatype-to-dataset-variables-during-proc/m-p/657597#M197073</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-11T17:01:08Z</dc:date>
    </item>
  </channel>
</rss>

