<?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 Output to One Record After Assiging Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535827#M147179</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is really good. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/48773"&gt;@FollinLane&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should "output after each iteration" be interpreted as output after each variable is extracted or output after processing of each record. In the latter case, you could add a transpose step after PGStats' excellent code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc transpose data=have out=want let;
   by obs;
   id field;
   var value;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Feb 2019 11:09:26 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2019-02-15T11:09:26Z</dc:date>
    <item>
      <title>How to Output to One Record After Assiging Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535718#M147137</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm reading in a file using the code below.&amp;nbsp; I'm new as using&amp;nbsp;the scan function and&amp;nbsp;would like to know how to output to the record after each iteration of through the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testdata2;
    infile mysource lrecl = 6807 truncover scanover;
        input
            @'"UserEmail"|"metadata_value":"' user_email $100.
			@'"ProductVersion"|"metadata_value":"' prod_version $20.
			@'"SourceEvent"|"metadata_value":"' source_event $30.
			@'"ProcessTotalWaitTime"|"metadata_value":"' PT_WaitTime $10.
			;

        user_email = scan(user_email,1,'"');
		prod_version = scan(prod_version,1,'"');
		source_event = scan(source_event,1,'"');
		PT_WaitTime = scan(PT_WaitTime,1,'"');

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 19:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535718#M147137</guid>
      <dc:creator>FollinLane</dc:creator>
      <dc:date>2019-02-14T19:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Output to One Record After Assiging Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535747#M147146</link>
      <description>&lt;P&gt;It's not clear what this means:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I'm new as using&amp;nbsp;the scan function and&amp;nbsp;would like to know how to output to the record after each iteration of through the code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Your new data set, testdata2, should have a record for each line in your source data file.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you were trying to remove the quotes with the SCAN() function, COMPRESS() or DEQUOTE() which removes quotes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/48773"&gt;@FollinLane&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm reading in a file using the code below.&amp;nbsp; I'm new as using&amp;nbsp;the scan function and&amp;nbsp;would like to know how to output to the record after each iteration of through the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testdata2;
    infile mysource lrecl = 6807 truncover scanover;
        input
            @'"UserEmail"|"metadata_value":"' user_email $100.
			@'"ProductVersion"|"metadata_value":"' prod_version $20.
			@'"SourceEvent"|"metadata_value":"' source_event $30.
			@'"ProcessTotalWaitTime"|"metadata_value":"' PT_WaitTime $10.
			;

        user_email = scan(user_email,1,'"');
		prod_version = scan(prod_version,1,'"');
		source_event = scan(source_event,1,'"');
		PT_WaitTime = scan(PT_WaitTime,1,'"');

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 20:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535747#M147146</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-14T20:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to Output to One Record After Assiging Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535797#M147166</link>
      <description>&lt;P&gt;You may extract all fields and values with the help of regular expression processing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
if not prxId then prxId + prxParse('/"metadata_name":"(.*?)"\|"metadata_value":"(.*?)"/');
infile "&amp;amp;sasforum.\Datasets\test.txt" truncover;
input line $1200.;
obs + 1;
length field $32 value $128;
start = 1; stop = -1;
call prxnext(prxId, start, stop, line, pos, len);
do while (pos &amp;gt; 0);
    field = prxPosn(prxId, 1, line);
    value = prxPosn(prxId, 2, line);
    output;
    call prxnext(prxId, start, stop, line, pos, len);
    end;
drop prxId line start stop pos len; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;     obs  field                             value
------------------------------------------------------------------------------------
       1  UserEmail                         user1@mycompany.org
       1  ProductVersion                    8.0.2009.0
       1  SourceEvent                       IdleEvent|1/30/2019 12:22:11 AM
       1  ProcessTotalWaitTime              0
       1  KeyPressCount                     2
       1  ErrorKeyPressCount                0
       1  CtrlC_Count                       0
       1  CtrlV_Count                       0
       1  CtrlX_Count                       0
       1  MouseClickCount                   4
       1  MouseWheelCount                   0
       1  WindowMoveSizeCount               0
       1  ScrollCount                       0
       1  HasScreenMapping                  True
       1  IsTestScreenMapping               False
       1  IsTestUser                        False
       2  UserEmail                         user2@mycompany.org
       2  ProductVersion                    8.0.2009.0
       2  SourceEvent                       ForegroundChanged|66570|0|0|0|179953
       2  ProcessTotalWaitTime              0
.....&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Feb 2019 05:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535797#M147166</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-02-15T05:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Output to One Record After Assiging Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535827#M147179</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is really good. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/48773"&gt;@FollinLane&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should "output after each iteration" be interpreted as output after each variable is extracted or output after processing of each record. In the latter case, you could add a transpose step after PGStats' excellent code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc transpose data=have out=want let;
   by obs;
   id field;
   var value;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 11:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535827#M147179</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-02-15T11:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Output to One Record After Assiging Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535840#M147182</link>
      <description>Sorry for the omission but I was trying to output after processing each record. For the sake of getting too detailed I got some strange results where the output seemed to be missing records or showing a partial record. Thanks for the the additional help!</description>
      <pubDate>Fri, 15 Feb 2019 12:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535840#M147182</guid>
      <dc:creator>FollinLane</dc:creator>
      <dc:date>2019-02-15T12:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Output to One Record After Assiging Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535857#M147192</link>
      <description>&lt;P&gt;This helps a lot.&amp;nbsp; I will need to study it more.&amp;nbsp; Along with what&amp;nbsp;&lt;SPAN&gt;ErikLund_Jensen posted I think I have the solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 14:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Output-to-One-Record-After-Assiging-Values/m-p/535857#M147192</guid>
      <dc:creator>FollinLane</dc:creator>
      <dc:date>2019-02-15T14:23:57Z</dc:date>
    </item>
  </channel>
</rss>

