<?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: SAS program to find Upload match download in a .csv file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848136#M335324</link>
    <description>&lt;P&gt;Thank you for the solution! Perhaps i was not clear with the solution I was looking for.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the final output, I would like row 3 to have download_flag= 'No' since for that file_name action upload does not have action download.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically,&amp;nbsp;&lt;/P&gt;&lt;P&gt;If file_name matches, check Action variable has both Upload and Download for that file_name. If true, Download_flag = "Yes" else "NO"&lt;/P&gt;</description>
    <pubDate>Tue, 06 Dec 2022 15:40:10 GMT</pubDate>
    <dc:creator>Kp1234</dc:creator>
    <dc:date>2022-12-06T15:40:10Z</dc:date>
    <item>
      <title>SAS program to find Upload match download in a .csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/847949#M335232</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Dataset which is a .csv file (Comma Seperated):&lt;/P&gt;&lt;P&gt;Header: ID,"Folder Path","File Name","Log Time",Action,"Login Name",IPAddress,"Transfer Size",Duration&lt;/P&gt;&lt;P&gt;Row1:1344624,"/Distribution/Projects/WUXI-EDO/Input","&lt;FONT color="#008000"&gt;C12345_xxx_wxp_img_20221013_114200_349.cum&lt;/FONT&gt;",,"&lt;FONT color="#0000FF"&gt;file_download&lt;/FONT&gt;",mft2sftp,"172.24.147.36",46438, Row2:13445945,"/Distribution/Projects/WUXI-EDO/Input","&lt;FONT color="#008000"&gt;C12345_xxx_wxp_img_20221013_114200_349.cum&lt;/FONT&gt;",,"&lt;FONT color="#0000FF"&gt;file_upload&lt;/FONT&gt;",hud8,"204.134.192.105",46438,&lt;/P&gt;&lt;P&gt;Row3:13442235,"/Distribution/Projects/WUXI-EDO/Input","C12345_xxx_npn_img_20221014_113344_600.cum",,"file_upload",kp123,"204.134.192.105",46438,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I want to flag any File Name upload which does not have a corresponding download.&amp;nbsp; In the above example, The expected output is ROW 3 since it does not contain a "file_download" row&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data alldata_status_1;&lt;BR /&gt;set alldata;&lt;/P&gt;&lt;P&gt;do;&lt;BR /&gt;if File_Name^= ' ' ;&lt;BR /&gt;if action in ('file_upload','file_download')&lt;BR /&gt;then download_flag = 'yes';&lt;BR /&gt;else download_flag = 'no';&lt;/P&gt;&lt;P&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Download_flag since It will help me subset the datasets.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 20:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/847949#M335232</guid>
      <dc:creator>Kp1234</dc:creator>
      <dc:date>2022-12-05T20:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS program to find Upload match download in a .csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848015#M335277</link>
      <description>&lt;P&gt;Check your CSV file once imported. I strongly suspect your "Action" column isn't populated because it coincides with double comma delimiters (,,) in your data rows.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 00:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848015#M335277</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-12-06T00:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS program to find Upload match download in a .csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848024#M335280</link>
      <description>&lt;P&gt;Does your file really have that extra stuff at the start of each line?&amp;nbsp; Why is ROW2 in the middle of ROW1?&lt;/P&gt;
&lt;PRE&gt;Header: ID,"Folder Path","File Name","Log Time",Action,"Login Name",IPAddress,"Transfer Size",Duration
Row1:1344624,"/Distribution/Projects/WUXI-EDO/Input","C12345_xxx_wxp_img_20221013_114200_349.cum",,"file_download",mft2sftp,"172.24.147.36",46438, Row2:13445945,"/Distribution/Projects/WUXI-EDO/Input","C12345_xxx_wxp_img_20221013_114200_349.cum",,"file_upload",hud8,"204.134.192.105",46438,
Row3:13442235,"/Distribution/Projects/WUXI-EDO/Input","C12345_xxx_npn_img_20221014_113344_600.cum",,"file_upload",kp123,"204.134.192.105",46438,&lt;/PRE&gt;
&lt;P&gt;Or is all of that an artifact of typing/pasting the lines into the comment window instead of the pop-up window that would preserve the formatting?&lt;/P&gt;
&lt;PRE&gt;ID,"Folder Path","File Name","Log Time",Action,"Login Name",IPAddress,"Transfer Size",Duration
1344624,"/Distribution/Projects/WUXI-EDO/Input","C12345_xxx_wxp_img_20221013_114200_349.cum",,"file_download",mft2sftp,"172.24.147.36",46438, 
13445945,"/Distribution/Projects/WUXI-EDO/Input","C12345_xxx_wxp_img_20221013_114200_349.cum",,"file_upload",hud8,"204.134.192.105",46438,
13442235,"/Distribution/Projects/WUXI-EDO/Input","C12345_xxx_npn_img_20221014_113344_600.cum",,"file_upload",kp123,"204.134.192.105",46438,&lt;/PRE&gt;
&lt;P&gt;If the file looks like the latter then your code should work fine although you should remove the unnecessary DO and matching END as they add nothing at all to the logic, just confusion for the programmer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc import dbms=csv file=sample out=want replace ;
run;

data want2;
  set want;
  if File_Name^= ' ' ;
  if action in ('file_upload','file_download') then download_flag = 'yes';
  else download_flag = 'no';
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1670297084747.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78089i303F42F55A6BB605/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1670297084747.png" alt="Tom_0-1670297084747.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;WARNING:&amp;nbsp; If you somehow have accidentally set the VALIDVARNAME option to ANY before running the PROC IMPORT step then the third columns variable name will be &lt;FONT face="courier new,courier"&gt;"File Name"n&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;File_Name&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Or if you wrote your own data step to read the file then use the variable names you created.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 03:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848024#M335280</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-06T03:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS program to find Upload match download in a .csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848136#M335324</link>
      <description>&lt;P&gt;Thank you for the solution! Perhaps i was not clear with the solution I was looking for.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the final output, I would like row 3 to have download_flag= 'No' since for that file_name action upload does not have action download.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically,&amp;nbsp;&lt;/P&gt;&lt;P&gt;If file_name matches, check Action variable has both Upload and Download for that file_name. If true, Download_flag = "Yes" else "NO"&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 15:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848136#M335324</guid>
      <dc:creator>Kp1234</dc:creator>
      <dc:date>2022-12-06T15:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS program to find Upload match download in a .csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848141#M335326</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304341"&gt;@Kp1234&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for the solution! Perhaps i was not clear with the solution I was looking for.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the final output, I would like row 3 to have download_flag= 'No' since for that file_name action upload does not have action download.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If file_name matches, check Action variable has both Upload and Download for that file_name. If true, Download_flag = "Yes" else "NO"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So the only way that makes any sense is if what you mean is that you want to check if the same file has records with both upload and download actions. Which means it is not something you can do by checking just one observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table check as 
  select file_name
       , sum( action = 'file_upload') as uploads
       , sum( action = 'file_download') as downloads
  from have
  group by file_name
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now with that level of information you can check if a file had both upload and download records.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set check;
  if uploads and downloads then want='YES';
  else want='NO';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Dec 2022 15:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-program-to-find-Upload-match-download-in-a-csv-file/m-p/848141#M335326</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-06T15:55:57Z</dc:date>
    </item>
  </channel>
</rss>

