SAS: Taking Date data in DD-MMM-YYYY format from a csv file in a date format in a permanent data set

余生长醉 提交于 2019-12-24 10:59:11

问题


I would like to import data from a csv file in a permanent data set which has this date column with data format like "dd-mmm-yyyy" like "22-FEB-1990". I want this to be imported as date format inside the data set too. I have tried many format informats but i am not getting anything in the column.

Here is the code i wrote(While I commented out certain things I have tested all the permutations and combinations with the formats and informats i could think of):

    libname asgn1 "C:\Users\*****\abc";          
    data asgn1.Car_sales_1_1;                
          infile  "C:\Users\********\Car_sales.csv" dsd dlm="," FIRSTOBS=2 ;
          input Manufacturer $ Model $ Fuel_efficiency Latest_Launch; 
          * format Latest_Launch mmddyy10.;
          * informat  Latest_Launch mmddyy10.;             
    run; 

Please help...


回答1:


Change your informat to date11. (dd-mmm-yyyy).

SAS Informats by Category > http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001239776.htm




回答2:


I tried the following code and I got just the result I wanted....Thanks @Chris J

    libname asgn1 "C:\Users\*****\abc";          
       data asgn1.Car_sales_1_1;                
      infile  "C:\Users\********\Car_sales.csv" dsd dlm="," FIRSTOBS=2 ;
      input Manufacturer $ Model $ Fuel_efficiency Latest_Launch; 
      informat  Latest_Launch date11.;
      format Latest_Launch ddmmyy10.;             
    run; 


来源:https://stackoverflow.com/questions/26010783/sas-taking-date-data-in-dd-mmm-yyyy-format-from-a-csv-file-in-a-date-format-in

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!