<?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: Date issues between a csv file and SAS Studio in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554443#M9507</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105760"&gt;@BoboTheFool&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;Is there a way in SAS that I can change the format, or do I have to go to the CSV file and change all of my dates (although none of the options are SAS agreeable either)?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Change how you read it in so it's read correctly as a SAS date instead. Try either the anydtdte or date9 INFORMAT. An Informat specifies what format the variable is in to read it in correctly. A format specifies what the display or output value will look like.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm surprised you're reading in your other variables, snow depth and precipitation as characters as well. You may want to modify those as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname Adam '/home/adamrowland0';


data Adam.InputData;
   
infile "/home/adamrowland0/sasuser.v94/Stat 510 Final Data Set.csv" dsd;
informat date anydtdte.;&lt;BR /&gt;format date date9.;
*informat date date9.;
   input Date
   	 High 
   	 Low
   	 Precip  $
   	 Snow $
   	 SnowDepth $;

  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Random suggestions - don't call a data set final, that's a recipe for confusion later on especially as you work through it. If it's the cleansed input data maybe name it that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also wouldn't recommend saving files in SASUSERv9.4, it's not a great place to store files, create a library for each project. It's also often locked down in many installations so you can't do it - SAS UE for example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can convert after the fact using an INPUT() to convert a character variable to numeric, but best practice is to read it in correctly in the first place. Note you cannot use the same variable name to convert a variable type in SAS, you must use a new name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;precip_numeric = input(precip, 8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You probably want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Adam.InputData;
   
infile "/home/adamrowland0/sasuser.v94/Stat 510 Final Data Set.csv" dsd;
informat date anydtdte.;
format date date9.;
*informat date date9.;

   input Date
   	 High 
   	 Low
   	 Precip  
   	 Snow 
   	 SnowDepth ;

  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105760"&gt;@BoboTheFool&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a csv file which has 6 variables - Day, HIgh, Low, Precip, Snow, and SnowDepth.&amp;nbsp; In the CSV file the date displays as 1-Jan-2018, and if I make Day a character variable it reads in the same way, but I cannot do any manipulations with it, as it isn't in a SAS defined format.&amp;nbsp; Is there a way in SAS that I can change the format, or do I have to go to the CSV file and change all of my dates (although none of the options are SAS agreeable either)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1-Jan-2018 -11.9 -24 0 0 2.99&lt;BR /&gt;2-Jan-2018 -0.9 -23.1 0 0 2.99&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname Adam '/home/adamrowland0';
data Adam.Final;
   infile "/home/adamrowland0/sasuser.v94/Stat 510 Final Data Set.csv" dsd;
   input Day $
   	 High 
   	 Low
   	 Precip  $
   	 Snow $
   	 SnowDepth $;

  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Thank you for any help you can provide.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Adam&lt;/FONT&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 27 Apr 2019 03:32:56 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-04-27T03:32:56Z</dc:date>
    <item>
      <title>Date issues between a csv file and SAS Studio</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554440#M9505</link>
      <description>&lt;P&gt;I have a csv file which has 6 variables - Day, HIgh, Low, Precip, Snow, and SnowDepth.&amp;nbsp; In the CSV file the date displays as 1-Jan-2018, and if I make Day a character variable it reads in the same way, but I cannot do any manipulations with it, as it isn't in a SAS defined format.&amp;nbsp; Is there a way in SAS that I can change the format, or do I have to go to the CSV file and change all of my dates (although none of the options are SAS agreeable either)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1-Jan-2018 -11.9 -24 0 0 2.99&lt;BR /&gt;2-Jan-2018 -0.9 -23.1 0 0 2.99&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname Adam '/home/adamrowland0';
data Adam.Final;
   infile "/home/adamrowland0/sasuser.v94/Stat 510 Final Data Set.csv" dsd;
   input Day $
   	 High 
   	 Low
   	 Precip  $
   	 Snow $
   	 SnowDepth $;

  
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Thank you for any help you can provide.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Adam&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 27 Apr 2019 02:28:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554440#M9505</guid>
      <dc:creator>BoboTheFool</dc:creator>
      <dc:date>2019-04-27T02:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Date issues between a csv file and SAS Studio</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554442#M9506</link>
      <description>&lt;P&gt;Change your input statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input
  Day :date11.
  High
  Low
  Precip
  Snow
  SnowDepth
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so that the dates are read correctly, and the numbers as numbers. Assign a date format to the day column.&lt;/P&gt;
&lt;P&gt;Add a proper delimiter in the infile statement, if it is really a csv file (comma separated).&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 03:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554442#M9506</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-27T03:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Date issues between a csv file and SAS Studio</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554443#M9507</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105760"&gt;@BoboTheFool&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;Is there a way in SAS that I can change the format, or do I have to go to the CSV file and change all of my dates (although none of the options are SAS agreeable either)?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Change how you read it in so it's read correctly as a SAS date instead. Try either the anydtdte or date9 INFORMAT. An Informat specifies what format the variable is in to read it in correctly. A format specifies what the display or output value will look like.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm surprised you're reading in your other variables, snow depth and precipitation as characters as well. You may want to modify those as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname Adam '/home/adamrowland0';


data Adam.InputData;
   
infile "/home/adamrowland0/sasuser.v94/Stat 510 Final Data Set.csv" dsd;
informat date anydtdte.;&lt;BR /&gt;format date date9.;
*informat date date9.;
   input Date
   	 High 
   	 Low
   	 Precip  $
   	 Snow $
   	 SnowDepth $;

  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Random suggestions - don't call a data set final, that's a recipe for confusion later on especially as you work through it. If it's the cleansed input data maybe name it that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also wouldn't recommend saving files in SASUSERv9.4, it's not a great place to store files, create a library for each project. It's also often locked down in many installations so you can't do it - SAS UE for example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can convert after the fact using an INPUT() to convert a character variable to numeric, but best practice is to read it in correctly in the first place. Note you cannot use the same variable name to convert a variable type in SAS, you must use a new name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;precip_numeric = input(precip, 8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You probably want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Adam.InputData;
   
infile "/home/adamrowland0/sasuser.v94/Stat 510 Final Data Set.csv" dsd;
informat date anydtdte.;
format date date9.;
*informat date date9.;

   input Date
   	 High 
   	 Low
   	 Precip  
   	 Snow 
   	 SnowDepth ;

  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105760"&gt;@BoboTheFool&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a csv file which has 6 variables - Day, HIgh, Low, Precip, Snow, and SnowDepth.&amp;nbsp; In the CSV file the date displays as 1-Jan-2018, and if I make Day a character variable it reads in the same way, but I cannot do any manipulations with it, as it isn't in a SAS defined format.&amp;nbsp; Is there a way in SAS that I can change the format, or do I have to go to the CSV file and change all of my dates (although none of the options are SAS agreeable either)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1-Jan-2018 -11.9 -24 0 0 2.99&lt;BR /&gt;2-Jan-2018 -0.9 -23.1 0 0 2.99&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname Adam '/home/adamrowland0';
data Adam.Final;
   infile "/home/adamrowland0/sasuser.v94/Stat 510 Final Data Set.csv" dsd;
   input Day $
   	 High 
   	 Low
   	 Precip  $
   	 Snow $
   	 SnowDepth $;

  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Thank you for any help you can provide.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Adam&lt;/FONT&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 03:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554443#M9507</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-27T03:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Date issues between a csv file and SAS Studio</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554482#M9511</link>
      <description>Thank you for the help! The reason I am reading in the last three variables as character variables is due to some of the values being 'T' instead of a number. While it automatically changes the 'T' to a '.' when it reads it in, the assignment I have necessitates me changing the 'T' to a proper missing denotation, '.', after the dataset has been read in, so I have to read them in as character values and then change them to numeric after changing them over. A lot of extra code, to be honest.</description>
      <pubDate>Sat, 27 Apr 2019 15:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554482#M9511</guid>
      <dc:creator>BoboTheFool</dc:creator>
      <dc:date>2019-04-27T15:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Date issues between a csv file and SAS Studio</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554489#M9514</link>
      <description>That makes some sense, since you can have data sets with T to indicate missing or Z to indicate not measured and Y to indicate instrument failure. Basically you can have missing values for many reasons and sometimes that's denoted by using different letters to indicate the type of missing. You may need to handle them differently so reading them in as character and converting after the fact can make sense.</description>
      <pubDate>Sat, 27 Apr 2019 16:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554489#M9514</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-27T16:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Date issues between a csv file and SAS Studio</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554741#M9565</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105760"&gt;@BoboTheFool&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for the help! The reason I am reading in the last three variables as character variables is due to some of the values being 'T' instead of a number. While it automatically changes the 'T' to a '.' when it reads it in, the assignment I have necessitates me changing the 'T' to a proper missing denotation, '.', after the dataset has been read in, so I have to read them in as character values and then change them to numeric after changing them over. A lot of extra code, to be honest.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can use custom informats to handle such things. Example:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
invalue trace
'T'= .T
other = [F8.]
;
run;

data example;
   informat x trace.;
   input x;
datalines;
-11.9
T
17.3
;
run;&lt;/PRE&gt;
&lt;P&gt;The above uses a special missing that by default shows the letter assigned with the special missing or a custom format could be used to display a different value. The numeric value is still missing and would not be used for calculations.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 15:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554741#M9565</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-29T15:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Date issues between a csv file and SAS Studio</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554752#M9566</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105760"&gt;@BoboTheFool&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for the help! The reason I am reading in the last three variables as character variables is due to some of the values being 'T' instead of a number. While it automatically changes the 'T' to a '.' when it reads it in, the assignment I have necessitates me changing the 'T' to a proper missing denotation, '.', after the dataset has been read in, so I have to read them in as character values and then change them to numeric after changing them over. A lot of extra code, to be honest.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is what the MISSING statement is for.&amp;nbsp; You use that to tell SAS which single letters it should read as special missing values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;missing t ;
data test;
  input id $ age ;
cards;
1 10
2 20
3  T
4  .
5 30
;

proc print; run;
proc means; run;
proc freq ;
 tables age / missing ;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Apr 2019 15:45:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-issues-between-a-csv-file-and-SAS-Studio/m-p/554752#M9566</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-29T15:45:00Z</dc:date>
    </item>
  </channel>
</rss>

