<?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: how to read a vcf to text to xls in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545017#M10003</link>
    <description>&lt;P&gt;By "thousands of vcf" do you mean you have one or more folders with multiple vcf files or one file with thousands of contacts?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example shows 4 values for TEL, how do you want those to appear in our data set? Could there be more than those 4 types? Fewer?&lt;/P&gt;
&lt;P&gt;Similarly the ADR implies that you might have more than one address. If so how&amp;nbsp;many and what types?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you want with the rest of the stuff shown? discarded?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something else that may have an impact: is that NOTE on a single line or may it be on more than one line?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It will help a bit if you can show how you expect your SAS file to look and then the Excel.&lt;/P&gt;
&lt;P&gt;Though I do wonder what you can do with this in Excel you can't in SAS.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2019 20:17:10 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-03-21T20:17:10Z</dc:date>
    <item>
      <title>how to read a vcf to text to xls</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545000#M10002</link>
      <description>&lt;P&gt;Dear SAS users,&amp;nbsp;&lt;/P&gt;&lt;P&gt;this task has been killing me.... Please help me if you can.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to develop a customer base by creating a xls out of thousands of vcf.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way I can automate this process instead of doing thousands times of copying and pasting?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;basically a vcf card looks like this in a text format, and I want to write a program that reading N, FN, ORG, TITLE, TEL, ADR&lt;/P&gt;&lt;P&gt;Even if I can't automate the entire process, I will be very appreciative if anyone can share any shortcuts!&lt;/P&gt;&lt;PRE class="sbody-pre"&gt;&lt;BR /&gt;BEGIN:VCARD&lt;BR /&gt;VERSION:2.1&lt;BR /&gt;N:Doe;John;;;&lt;BR /&gt;FN:John Doe&lt;BR /&gt;ORG:Doe Company, The;&lt;BR /&gt;TITLE: President&lt;BR /&gt;NOTE;ENCODING=QUOTED-PRINTABLE: This is a note associated with this&lt;BR /&gt;contact=0D=0A&lt;BR /&gt;TEL;WORK;VOICE:(987) 123-4567&lt;BR /&gt;TEL;HOME;VOICE:(987) 765-4321&lt;BR /&gt;TEL;CELL;VOICE:(987) 135-8642&lt;BR /&gt;TEL;WORK;FAX:(987) 246-1357&lt;BR /&gt;ADR;WORK:;;1234 North Street;Anytown;TX 751234;;United States of America&lt;BR /&gt;LABEL;WORK;ENCODING=QUOTED-PRINTABLE:1234 North Street=0D=0AAnytown, TX&lt;BR /&gt;751234 =0D=0AUnited States of America&lt;BR /&gt;URL:&lt;BR /&gt;URL:&amp;lt;WWLINK TYPE="GENERIC"&lt;BR /&gt;VALUE="http://www.doeweb.com"&amp;gt;http://www.doeweb.com&amp;lt;/WWLINK&amp;gt;&lt;BR /&gt;EMAIL;PREF;INTERNET:jdoe@nowhere.com&lt;BR /&gt;REV:19980114T170559Z&lt;BR /&gt;END:VCARD&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 19:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545000#M10002</guid>
      <dc:creator>tsai1108_gmail_com</dc:creator>
      <dc:date>2019-03-21T19:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to read a vcf to text to xls</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545017#M10003</link>
      <description>&lt;P&gt;By "thousands of vcf" do you mean you have one or more folders with multiple vcf files or one file with thousands of contacts?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example shows 4 values for TEL, how do you want those to appear in our data set? Could there be more than those 4 types? Fewer?&lt;/P&gt;
&lt;P&gt;Similarly the ADR implies that you might have more than one address. If so how&amp;nbsp;many and what types?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you want with the rest of the stuff shown? discarded?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something else that may have an impact: is that NOTE on a single line or may it be on more than one line?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It will help a bit if you can show how you expect your SAS file to look and then the Excel.&lt;/P&gt;
&lt;P&gt;Though I do wonder what you can do with this in Excel you can't in SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 20:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545017#M10003</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-21T20:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to read a vcf to text to xls</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545024#M10004</link>
      <description>&lt;P&gt;Hi ballardw;&lt;/P&gt;&lt;P&gt;so currently, I have downloaded all vcf manually, as I don't know how to code to download them directly from the web....&amp;nbsp;&lt;/P&gt;&lt;P&gt;I put all the downloaded vcfs (thousand of them in separate files) into one single folder categorized by company.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how i'd like to see my output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to put it in excel for now as I don't know how to make this happen using SAS. I am only familiar with structured data..... no clues of how to manipulate texts. I will be happy with two phone numbers and one address if there are multiple.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 20:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545024#M10004</guid>
      <dc:creator>tsai1108_gmail_com</dc:creator>
      <dc:date>2019-03-21T20:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to read a vcf to text to xls</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545049#M10005</link>
      <description>&lt;P&gt;Here is something that should help you get started.&lt;/P&gt;
&lt;PRE&gt;data example;
   informat n fn $25. org $40. title $25. phonework phonehome phonecell phonefax $20.
        adrwork $100.
   ;
   input @;
   /* see if we have found the beginning of a record*/
   if _infile_=:"BEGIN:VCARD" then do;
      input /    
            /@'N:' n
            /@'FN:' fn
            /@'ORG:' org
            /@'TITLE:' title 
      ;
      /* no into likely conditional reads*/
      do until (_infile_=:'TEL');
         input ;
      end;
      do while (_infile_=:'TEL');
         if index(_infile_,'WORK')&amp;gt;0 then do;
            if index(_infile_,'VOICE')&amp;gt;0 THEN phonework= substr(_infile_,index(_infile_,'('));
            ELSE IF index(_infile_,'FAX')&amp;gt;0 THEN phonefax= substr(_infile_,index(_infile_,'('));
         end;
         if index(_infile_,'HOME')&amp;gt;0 then phonehome= substr(_infile_,index(_infile_,'('));
         if index(_infile_,'CELL')&amp;gt;0 then phonecell= substr(_infile_,index(_infile_,'('));
         input;
      end;
      /* at this point you do something similar to reading the phones to 
         read address(es) */

      /* only output after reading the fields needed*/
      output;
   end;
   else input;
datalines4;
BEGIN:VCARD
VERSION:2.1
N:Doe;John;;;
FN:John Doe
ORG:Doe Company, The;
TITLE: President
NOTE;ENCODING=QUOTED-PRINTABLE: This is a note associated with this
contact=0D=0A
TEL;WORK;VOICE:(987) 123-4567
TEL;HOME;VOICE:(987) 765-4321
TEL;CELL;VOICE:(987) 135-8642
TEL;WORK;FAX:(987) 246-1357
ADR;WORK:;;1234 North Street;Anytown;TX 751234;;United States of America
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:1234 North Street=0D=0AAnytown, TX
751234 =0D=0AUnited States of America
URL:
URL:&amp;lt;WWLINK TYPE="GENERIC"
VALUE="http://www.doeweb.com"&amp;gt;http://www.doeweb.com&amp;lt;/WWLINK&amp;gt;
EMAIL;PREF;INTERNET:jdoe@nowhere.com
REV:19980114T170559Z
END:VCARD
;;;;
&lt;/PRE&gt;
&lt;P&gt;Key elements:&lt;/P&gt;
&lt;P&gt;INput is executeable, you can request an input any time you want while going through a file.&lt;/P&gt;
&lt;P&gt;The @ holds a current line.&lt;/P&gt;
&lt;P&gt;The /@ on an input says advance a line in the file (the /) and at the position the text is found, @'N:' for example start reading the variable name that follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_INFILE_ is an automatic variable that holds the value of the current line form the file being read. So you can parse it using any text search functions.&lt;/P&gt;
&lt;P&gt;I did not do anything to parse out the address because I am afraid that you are likely to found to may addresses that have different things missing or poorly formatted. I suspect your example has an error of a Zip code in the state field. Each of those ; in the ADR probably indicate a different value but I found reference to at least 3 different VCARD formats and the addresses are one of the things that changes. So you may need to actually read that VERSION information to know how to parse a specific card.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The serious logic goes into identifying which things are SKIPPED. I do not know what one of these might look like without an EMAIL for instance. I suspect you may not even have a line that starts with EMAIL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The forum has multiple examples of reading many similar files in a single data step. Search for one that uses the FILENAME option on an INFILE statement. That is used to restart reading from the top of a new file.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 21:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-read-a-vcf-to-text-to-xls/m-p/545049#M10005</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-21T21:04:18Z</dc:date>
    </item>
  </channel>
</rss>

