<?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 Reading data in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575114#M12795</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data dsn;
input empname$ 20. empcode ;
cards;
Oliver21070
Jack21071
Harry21072
Jacob20051
Charlie20008
George20058
William20010
;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want output below format&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EMPNAME&lt;/TD&gt;&lt;TD&gt;EMPCODE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Oliver&lt;/TD&gt;&lt;TD&gt;21070&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jack2&lt;/TD&gt;&lt;TD&gt;21071&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Harry&lt;/TD&gt;&lt;TD&gt;21072&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jacob&lt;/TD&gt;&lt;TD&gt;20051&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Charlie&lt;/TD&gt;&lt;TD&gt;20008&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;George&lt;/TD&gt;&lt;TD&gt;20058&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;William&lt;/TD&gt;&lt;TD&gt;20010&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jul 2019 08:06:29 GMT</pubDate>
    <dc:creator>BrahmanandaRao</dc:creator>
    <dc:date>2019-07-20T08:06:29Z</dc:date>
    <item>
      <title>Reading data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575114#M12795</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data dsn;
input empname$ 20. empcode ;
cards;
Oliver21070
Jack21071
Harry21072
Jacob20051
Charlie20008
George20058
William20010
;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want output below format&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EMPNAME&lt;/TD&gt;&lt;TD&gt;EMPCODE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Oliver&lt;/TD&gt;&lt;TD&gt;21070&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jack2&lt;/TD&gt;&lt;TD&gt;21071&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Harry&lt;/TD&gt;&lt;TD&gt;21072&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jacob&lt;/TD&gt;&lt;TD&gt;20051&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Charlie&lt;/TD&gt;&lt;TD&gt;20008&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;George&lt;/TD&gt;&lt;TD&gt;20058&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;William&lt;/TD&gt;&lt;TD&gt;20010&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 08:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575114#M12795</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-07-20T08:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575119#M12797</link>
      <description>&lt;P&gt;Values are strings. The Input statement cann't determine the delimiting position from string to number. Here is solution which reads the values as "STR" and splits it into empname and empcode:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data dsn;
input str $20.;
cards;
Oliver21070
Jack21071
Harry21072
Jacob20051
Charlie20008
George20058
William20010
;
run;

data want;
   set dsn;
   length empname $20;
   empname=substr(str,1,anydigit(str)-1);
   empcode = compress(str,,'kd');
drop str;
run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Jul 2019 08:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575119#M12797</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-07-20T08:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575120#M12798</link>
      <description>&lt;P&gt;Assuming the last 5 positions in the source data should get mapped into variable Empcode below syntax should work as well.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample(drop=_:);
  infile datalines truncover;
  input @;
  _fwidth=lengthn(_infile_)-5;
  input empname $varying20. _fwidth empcode $5.;
  datalines;
Oliver21070
Jack21071
Harry21072
Jacob20051
Charlie20008
George20058
William20010
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Jul 2019 09:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575120#M12798</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-07-20T09:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575135#M12809</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn;
input ;
empname=compress(_infile_,,'d');
empcode=compress(_infile_,,'kd');
cards;
Oliver21070
Jack21071
Harry21072
Jacob20051
Charlie20008
George20058
William20010
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Compress would default to &lt;SPAN&gt;the length of the first argument.&lt;/SPAN&gt;. You could use a length statement to assign an appropriate length&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 15:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575135#M12809</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-20T15:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575148#M12812</link>
      <description>&lt;P&gt;Can you fix the data so that there is some delimiter between the two fields? Or so that the second field starts in a specific column?&lt;/P&gt;
&lt;P&gt;Your program is assuming that EMPCODE starts in column 21.&amp;nbsp; Also EMPCODE is probably not a number. There is no value in taking the mean of EMPCODE.&lt;/P&gt;
&lt;P&gt;So if you put the data into fixed positions the code could look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn;
  input empname $20. empcode $5.;
cards;
Oliver              21070
Jack                21071
Harry               21072
Jacob               20051
Charlie             20008
George              20058
William             20010
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could put a delimiter between the two fields and read it using LIST MDOE instead of FORMATTED input.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn;
  infile cards dsd dlm='|' truncover ;
  length empname $20 empcode $5;
  input empname empcode ;
cards;
Oliver  |21070
Jack    |21071
Harry   |21072
Jacob   |20051
Charlie |20008
George  |20058
William |20010
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: do not leave a space in the middle of your informat.&amp;nbsp; In this line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input empname$ 20. empcode ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The $ is telling SAS to define EMPNAME as a character variable.&amp;nbsp; Then when it sees the INFORMAT of 20. it&amp;nbsp; will recognize that it is the wrong type of informat for a character variable. So SAS will silently convert by adding $ in front for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 15:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575148#M12812</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-20T15:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575149#M12813</link>
      <description>&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;brilliant code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 16:06:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575149#M12813</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-07-20T16:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575150#M12814</link>
      <description>&lt;P&gt;Hi Tom&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp; for your support&amp;nbsp;&lt;/P&gt;&lt;P&gt;here we have small data to set pipe symbol in between two variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what if very huge data can we edit manually&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 16:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575150#M12814</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-07-20T16:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575151#M12815</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp; for your support&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here we have small data to set pipe symbol in between two variables&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what if very huge data can we edit manually&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First step is to send the data back to who ever created it and ask that it be created in a readable format.&lt;/P&gt;
&lt;P&gt;If that fails then you will need to use one of the methods posted to attempt the tease the two field apart.&amp;nbsp; You will probably want to do some QC on the result to make sure that the algorithm worked for all cases.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 16:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-data/m-p/575151#M12815</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-20T16:34:40Z</dc:date>
    </item>
  </channel>
</rss>

