<?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: Getting wrong output while importing a csv file with  | (Pipe) delimited in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809627#M319279</link>
    <description>&lt;P&gt;The ZD. informat is not compatible with the list format. You also have another problem, namely that you actually have 3, not 2 zoned decimal variables, one of which if occasionally missing (the "||" parts of your shown input).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get around that I would suggest to read the zoned decimals into temporary text variables, and then parse them, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Test;
Infile cards DSD DLM="|" Truncover;
length _temp1-_temp3 $2;
Input ID : 3. _temp1  Name : $20. _temp2 _temp3 Last : $5.;
testZD1=input(_temp1,?? zd1.);
testZD2=input(_temp2,?? zd2.);
testZD3=input(_temp3,?? zd2.);
drop _:;
cards;
101|}|Test 1|0}||Last
101|}|Test Line|0}||Last
101|}|Test|0}|12|Last
101|}|Test Other|0}|12|Last
;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It may be possible to read the zoned decimals directly, but only if they are fixed length, and the missing values have length 0.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Apr 2022 07:37:56 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2022-04-25T07:37:56Z</dc:date>
    <item>
      <title>Getting wrong output while importing a csv file with  | (Pipe) delimited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809623#M319276</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;We were trying to import a csv file with | (pipe) delimited, but after importing either the columns are getting shifted to next column or its populating as blank. Please find the samples data and code below. Please help us to resolve the issue with your suggestion.&lt;/P&gt;&lt;P&gt;Your help will be highly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CSV file:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;101|}|Test 1|0}||Last&lt;BR /&gt;101|}|Test Line|0}||Last&lt;BR /&gt;101|}|Test|0}|12|Last&lt;BR /&gt;101|}|Test Other|0}|12|Last&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Code using to extract the data:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Data Test;&lt;BR /&gt;Infile '' DSD DLM="|" Truncover;&lt;BR /&gt;Input ID : 3. TestZD1. Name : $20. TestZD2 ZD2. Last : $5.;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Values are shifting to next variable if using ZDw. informats.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Not able to use the colon (:) operator while extracting into ZDw. informat. &amp;amp; getting warning messages if using the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;WARNING 151-185:&lt;/STRONG&gt; List input is incompatible with the specified binary informat. Formatted input will be used.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 06:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809623#M319276</guid>
      <dc:creator>Vimal0808</dc:creator>
      <dc:date>2022-04-25T06:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getting wrong output while importing a csv file with  | (Pipe) delimited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809627#M319279</link>
      <description>&lt;P&gt;The ZD. informat is not compatible with the list format. You also have another problem, namely that you actually have 3, not 2 zoned decimal variables, one of which if occasionally missing (the "||" parts of your shown input).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get around that I would suggest to read the zoned decimals into temporary text variables, and then parse them, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Test;
Infile cards DSD DLM="|" Truncover;
length _temp1-_temp3 $2;
Input ID : 3. _temp1  Name : $20. _temp2 _temp3 Last : $5.;
testZD1=input(_temp1,?? zd1.);
testZD2=input(_temp2,?? zd2.);
testZD3=input(_temp3,?? zd2.);
drop _:;
cards;
101|}|Test 1|0}||Last
101|}|Test Line|0}||Last
101|}|Test|0}|12|Last
101|}|Test Other|0}|12|Last
;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It may be possible to read the zoned decimals directly, but only if they are fixed length, and the missing values have length 0.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 07:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809627#M319279</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-04-25T07:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Getting wrong output while importing a csv file with  | (Pipe) delimited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809646#M319291</link>
      <description>&lt;P&gt;Why not use SCAN() ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Test2;
input;
ID=input(scan(_infile_,1,'|','mq'),best.); 
TestZD1=input(scan(_infile_,2,'|','mq'),zd1.); 
length name $ 200;
Name=scan(_infile_,3,'|','mq'); 
TestZD2=input(scan(_infile_,4,'|','mq'),zd2.); 
TestZD3=input(scan(_infile_,5,'|','mq'),zd2.); 
length Last $ 200;
Last=scan(_infile_,6,'|','mq'); 
cards;
101|}|Test 1|0}||Last
101|}|Test Line|0}||Last
101|}|Test|0}|12|Last
101|}|Test Other|0}|12|Last
;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Apr 2022 10:48:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809646#M319291</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-04-25T10:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Getting wrong output while importing a csv file with  | (Pipe) delimited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809709#M319313</link>
      <description>&lt;P&gt;Thank you for your help!!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 14:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-wrong-output-while-importing-a-csv-file-with-Pipe/m-p/809709#M319313</guid>
      <dc:creator>Vimal0808</dc:creator>
      <dc:date>2022-04-25T14:37:45Z</dc:date>
    </item>
  </channel>
</rss>

