<?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: need I use the input function? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784913#M81307</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tianerhu_0-1638972349958.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66507iA1D560D2D0633EA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tianerhu_0-1638972349958.png" alt="tianerhu_0-1638972349958.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Dec 2021 14:06:19 GMT</pubDate>
    <dc:creator>tianerhu</dc:creator>
    <dc:date>2021-12-08T14:06:19Z</dc:date>
    <item>
      <title>need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784895#M81304</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
  distinct 
    qtr(datepart(tran_date)) 
      as quarter, 
    year(datepart(tran_date)) 
      as year
from sales_q1;
&lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Do I need use the function input( ) to transfer the character variable to numeral variable ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable 'trans_date' is character variable.&lt;/P&gt;
&lt;P&gt;Like this : 01JAN17:09:43:00&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 13:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784895#M81304</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-12-08T13:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784896#M81305</link>
      <description>&lt;P&gt;Are you sure it isn't numeric with a format? What does PROC CONTENTS say?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 13:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784896#M81305</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-08T13:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784913#M81307</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tianerhu_0-1638972349958.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66507iA1D560D2D0633EA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tianerhu_0-1638972349958.png" alt="tianerhu_0-1638972349958.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 14:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784913#M81307</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-12-08T14:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784917#M81309</link>
      <description>&lt;P&gt;Yes, if you want to use DATEPART then it has to be numeric. Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year(datepart(input(tran_date,anydtdtm.))) as year&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Dec 2021 14:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784917#M81309</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-08T14:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784950#M81310</link>
      <description>&lt;P&gt;Yes, but go back and fix it in your data import or an earlier step so you're not doing it throughout your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 17:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784950#M81310</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-08T17:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784951#M81311</link>
      <description>&lt;P&gt;Yes.&lt;/P&gt;
&lt;P&gt;To convert strings like that use the DATETIME informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INPUT() function does not care if you use a width that is larger than the length of the string being read. The maximum width that DATETIME informat supports is 40.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(tran_date,datetime40.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 18:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784951#M81311</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-08T18:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784970#M81313</link>
      <description>&lt;P&gt;but , the code without using input() works . I import data using proc import , is this the reason?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile = "C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\test file.csv"
 out = test
 dbms = CSV
 replace
 ;
run;
proc print data = test;
run;
proc import datafile = "C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\Sales_Q1.csv"
 out = Sales_Q1
 dbms = CSV
 replace
 ;
run;
proc means data=sales_q1;
var price;
run;
proc sql;
select 
  distinct 
    qtr(datepart(tran_date)) 
      as quarter, 
    year(datepart(tran_date)) 
      as year
from sales_q1;
quit;
proc import datafile = "C:\SAS data and program\data\data from web source\Geo-targeting\Data Files/locations.csv"
 out = locations
 dbms = CSV
 replace
 ;
run;

proc import datafile = "C:\SAS data and program\data\data from web source\Geo-targeting\Data Files/postcode.csv"
 out = postcode
 dbms = CSV
 replace
 ;
run;
proc sql;
create table sales_q1_loc as
select a.*, b.os_x as store_x, b.os_y as store_y
from sales_q1 a, locations b
where a.store_postcode = b.postcode;
quit;
proc sql;
create table sales_q1_loc_pos as
select a.*, b.os_x as cust_x, b.os_y as cust_y
from sales_q1_loc a left join postcode b
on a.customer_postcode = b.postcode;
quit;
data sales_check;
set sales_q1_loc_pos;
where store_x = . or
      store_y = . or
      cust_x = . or
      cust_y = .;

keep customer_postcode store_postcode store_x store_y cust_x cust_y;
run;
proc print data = sales_check;
run;
proc contents data = apple.sales_q1;
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;*******************************************************************************************************************&lt;/P&gt;
&lt;P&gt;*******************************************************************************************************************&lt;/P&gt;
&lt;P&gt;*******************************************************************************************************************&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname apple 'C:\SAS data and program\data\data from web source\Geo-targeting\Data Files';
data apple.computers;
infile 'C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\computers.csv' dsd firstobs=2;
input configuration screen_size battery_hours ram processor_speed SSD $ HD_size $;
run;
data apple.locations;
infile 'C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\locations.csv' dsd firstobs=2;
input Postcode $ OS_X OS_Y Lat Long ;
run;
data apple.postcode;
infile 'C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\postcode.csv' dsd firstobs=2;
input Postcode $ OS_X OS_Y;
run;
data apple.sales_q1;
infile 'C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\sales_q1.csv' dsd firstobs=2;
length tran_date $ 16;
input tran_date $ Configuration Customer_Postcode $ Store_Postcode $ month price;
run;
proc contents data = apple.sales_q1;
run;
proc sql;
select 
  distinct 
    qtr(datepart(input(tran_date,datetime18.))) 
      as quarter, 
    year(datepart(input(tran_date,datetime18.))) 
      as year
from apple.sales_q1;
quit;

proc sql;
create table sales_q1_loc as
select a.*, b.os_x as store_x, b.os_y as store_y
from apple.sales_q1 a, apple.locations b
where a.store_postcode = b.postcode;
quit;

proc print data = sales_q1_loc(obs=10);
run;
proc sql;
create table sales_q1_loc_pos as
select a.*, b.os_x as cust_x, b.os_y as cust_y
from sales_q1_loc a left join apple.postcode b
on a.customer_postcode = b.postcode;
quit;
data sales_check;
set sales_q1_loc_pos;
where store_x = . or
      store_y = . or
      cust_x = . or
      cust_y = .;

keep customer_postcode store_postcode store_x store_y cust_x cust_y;
run;
proc means data = sales_check;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The last proc (proc means) in the first code , I can detect 9698 missing value .&lt;BR /&gt;The last proc (proc means) in the second code , I can detect 0 missing value.&lt;/P&gt;
&lt;P&gt;But, I just use different way to read data from raw file:&lt;/P&gt;
&lt;P&gt;the first code : proc import&lt;/P&gt;
&lt;P&gt;the second code : data step&lt;/P&gt;
&lt;P&gt;why ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 18:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784970#M81313</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-12-08T18:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784979#M81314</link>
      <description>&lt;P&gt;In this step you let PROC IMPORT make its best GUESS at how to define TRAN_DATE based on what it sees in just the first few lines of the CSV file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile = "C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\Sales_Q1.csv"
 out = Sales_Q1
 dbms = CSV
 replace
 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To see what decision it made check the resulting dataset with PROC CONTENTS.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=Sales_Q1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In this data step you set the variable tran_date&amp;nbsp; as character with a maximum length of 16 bytes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data apple.sales_q1;
infile 'C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\sales_q1.csv' dsd firstobs=2;
length tran_date $ 16;
input tran_date $ Configuration Customer_Postcode $ Store_Postcode $ month price;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want it to define TRAN_DATE as a DATETIME value then tell it what INFORMAT to use when reading the text from the CSV for that variable. And attach an appropriate format so the values are displayed in a way that humans will recognize.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data apple.sales_q1;
  infile 'C:\SAS data and program\data\data from web source\Geo-targeting\Data Files\sales_q1.csv' dsd firstobs=2;
  input tran_date :datetime. Configuration Customer_Postcode $ Store_Postcode $ month price;
  format tran_date datetime19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Dec 2021 19:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/784979#M81314</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-08T19:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: need I use the input function?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/785012#M81315</link>
      <description>Thank you .</description>
      <pubDate>Wed, 08 Dec 2021 20:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-I-use-the-input-function/m-p/785012#M81315</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-12-08T20:35:53Z</dc:date>
    </item>
  </channel>
</rss>

