<?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: unzip files with certain extension in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/unzip-files-with-certain-extension/m-p/269097#M7470</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3239"&gt;@tmcrouse﻿&lt;/a&gt;, it seems like you might need a two-pass approach for this. &amp;nbsp;First pass is to assemble the list of TXT files that you need to process, and then for each text file you find, generate a SAS program that does the work of reading in the data from it. &amp;nbsp;You don't say whether all of the text files have the same format -- it would be good if they do, as that will make things much easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code might look something like this...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename fromzip zip 'c:\temp\class.zip';
data contents(keep=memname isFolder);
 length memname $200 isFolder 8;
 fid=dopen("fromzip");
 if fid=0 then
  stop;
 memcount=dnum(fid);
 do i=1 to memcount;
  memname=dread(fid,i);
  /* check for trailing / in folder name */
  isFolder = (first(reverse(trim(memname)))='/');
  output;
 end;
 rc=dclose(fid);
run;

options source2;
filename sasprog temp;
data _null_;
 file sasprog;
 length line $ 100;
 set contents(keep=memname);
 lines = 'data in; infile intxt(' || memname || '); input; put _infile_; run;';
 put 'filename intxt ZIP "c:\temp\class.zip";' ;
 put line;
 put 'filename intxt clear;';
run;

%include sasprog;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 May 2016 04:00:24 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2016-05-09T04:00:24Z</dc:date>
    <item>
      <title>unzip files with certain extension</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/unzip-files-with-certain-extension/m-p/268011#M7439</link>
      <description>&lt;P&gt;I have had some great help on this board and Chris helped me with finding the right path to connect to a shared drive and finding the zipped files. I have 12 folders that have multiple zipped files and I was coding each zipped file as I will show in my code and each .txt file I need from the zipped file. But there are over 200 .txt files in this one zipped folder and I only need the files that have the extension detail.txt. The other files I can disregard. They are flagged.txt. Here is an example of what I have as code now and just want to find an easier way than going back and forth to the shared drive and typing in all these lengthy names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[code]&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;filename&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; fromzip &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;zip&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'\\agpcorp\files\va1\Private\managedcaresvcs\health-qualitymgmt\hedis rates_datasets_benchmarks\hedis 2017\datasets\2016_03_mar hedis 2017_my2016\me1\hedis2017_mar2016_md medicaidchip.zip'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; memname $&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;256&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; memname $;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;infile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; fromzip memvar=memname &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;=eof;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;eof=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;while&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(not eof);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; memname= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_infile_&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%_rye_mbr_benefit_16_rider16_detail.txt;&lt;/P&gt;
&lt;P&gt;adh_med_schizo_16_saa16_detail.txt;&lt;/P&gt;
&lt;P&gt;adhere_antipsy_16_am_saa16am_detail.txt;&lt;/P&gt;
&lt;P&gt;adol_well_care_16_ch_awc16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;adolesc_well_care_16_awc16_detail.txt;&lt;/P&gt;
&lt;P&gt;adult_bmi_16_am_aba16am_detail.txt;&lt;/P&gt;
&lt;P&gt;adult_bmi_assmt_16_aba16_detail.txt;&lt;/P&gt;
&lt;P&gt;adult_access_16_aap16_detail.txt;&lt;/P&gt;
&lt;P&gt;ambulatory_care_16_amb16_detail.txt;&lt;/P&gt;
&lt;P&gt;ambulatory_care_16_ch_amb16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;annual_dental_16_adv16_detail.txt;&lt;/P&gt;
&lt;P&gt;annual_mon_rx_16_am_mpm16am_detail.txt;&lt;/P&gt;
&lt;P&gt;annual_monitor_rx_16_mpm16_detail.txt;&lt;/P&gt;
&lt;P&gt;antemmedmgmntasthma16_mma16wl_detail.txt;&lt;/P&gt;
&lt;P&gt;antenatal_stds_16_am_ans16am_detail.txt;&lt;/P&gt;
&lt;P&gt;antibiotic_util_16_abx16_detail.txt;&lt;/P&gt;
&lt;P&gt;antidepr_meds_16_am_amm16am_detail.txt;&lt;/P&gt;
&lt;P&gt;antidepress_meds_16_amm16_detail.txt;&lt;/P&gt;
&lt;P&gt;anitpsy_psychosoc_16_app16_detail.txt;&lt;/P&gt;
&lt;P&gt;app_test_pharyng_16_cwp16_detail.txt;&lt;/P&gt;
&lt;P&gt;app_treatment_uri_16_uri16_detail.txt;&lt;/P&gt;
&lt;P&gt;asthma_admit_16_am_aar16am_detail.txt;&lt;/P&gt;
&lt;P&gt;asthma_med_ratio_16_amr16_detail.txt;&lt;/P&gt;
&lt;P&gt;avoid_abx_bronch_16_aab16_detail.txt;&lt;/P&gt;
&lt;P&gt;behavior_risk_16_ch_bra16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;breast_cancer_16_am_bcs16am_detail.txt;&lt;/P&gt;
&lt;P&gt;cahps_adult_survey_16_cpa16_detail.txt;&lt;/P&gt;
&lt;P&gt;cahps_child_16_ch_cpc16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;cahps_child_survey_16_cpc16_detail.txt;&lt;/P&gt;
&lt;P&gt;breast_cancer_16_bcs16_detail.txt;&lt;/P&gt;
&lt;P&gt;cardio_schizo_16_smc_16_detail.txt;&lt;/P&gt;
&lt;P&gt;care_trans_16_am_ctr16am_detail.txt;&lt;/P&gt;
&lt;P&gt;cervical_c_scr_16_am_ccs16am_detail.txt;&lt;/P&gt;
&lt;P&gt;chf_admit_16_am_chf16am_detail.txt;&lt;/P&gt;
&lt;P&gt;child_access_16_ch_cap16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;child_imm_w_lead_16_cis16q_detail.txt;&lt;/P&gt;
&lt;P&gt;childhood_imm_16_ch_cis16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;childhood_imm_16_cis16_detail.txt;&lt;/P&gt;
&lt;P&gt;childrens_access_16_cap16_detail.txt;&lt;/P&gt;
&lt;P&gt;chlamyd_screen_16_ch_chl16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;chlamydia_screen_16_chl16_detail.txt;&lt;/P&gt;
&lt;P&gt;chlamydia_scrn_16_am_chl16am_detail.txt;&lt;/P&gt;
&lt;P&gt;colorectal_cancer_16_col16_detail.txt;&lt;/P&gt;
&lt;P&gt;comp_diabetes_16_cdc16_detail.txt;&lt;/P&gt;
&lt;P&gt;control_hbp_16_am_cbp16am_detail.txt;&lt;/P&gt;
&lt;P&gt;control_high_bp_16_cbp16_detail.txt;&lt;/P&gt;
&lt;P&gt;copd_admit_16_am_cpr16am_detail.txt;&lt;/P&gt;
&lt;P&gt;csr_for_ntsv_16_ch_csr16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;dental_sealant_16_ch_sea16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;dev_scrn_1_3_16_ch_dsv16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;dev_scrn_age_1_16_ch_dvs16cha_detail.txt;&lt;/P&gt;
&lt;P&gt;dev_scrn_age_2_16_ch_dvs16chb_detail.txt;&lt;/P&gt;
&lt;P&gt;dev_scrn_age_3_16_ch_dvs16chc_detail.txt;&lt;/P&gt;
&lt;P&gt;diab_monit_schizo_16_smd16_detail.txt;&lt;/P&gt;
&lt;P&gt;diab_screen_schiz_16_ssd16_detail.txt;&lt;/P&gt;
&lt;P&gt;diabetes_a1c_16_am_cdc16am_detail.txt;&lt;/P&gt;
&lt;P&gt;diabetes_admit_16_am_dsr16am_detail.txt;&lt;/P&gt;
&lt;P&gt;diabetes_poor_16_am_hpc16am_detail.txt;&lt;/P&gt;
&lt;P&gt;dmard_rheum_arthr_16_art16_detail.txt;&lt;/P&gt;
&lt;P&gt;ed_utilization_16_edu16_detail.txt;&lt;/P&gt;
&lt;P&gt;elec_delivery_16_am_edr16am_detail.txt;&lt;/P&gt;
&lt;P&gt;fllwup_hosp_mh_16_ch_fuh16ch_detail.txt;&lt;/P&gt;
&lt;P&gt;cervical_cancer_16_ccs16_detail.txt;&lt;/P&gt;
&lt;P&gt;follow_up_hosp_mh_16_fuh16_detail.txt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;[\code]&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 17:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/unzip-files-with-certain-extension/m-p/268011#M7439</guid>
      <dc:creator>tmcrouse</dc:creator>
      <dc:date>2016-05-03T17:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: unzip files with certain extension</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/unzip-files-with-certain-extension/m-p/269097#M7470</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3239"&gt;@tmcrouse﻿&lt;/a&gt;, it seems like you might need a two-pass approach for this. &amp;nbsp;First pass is to assemble the list of TXT files that you need to process, and then for each text file you find, generate a SAS program that does the work of reading in the data from it. &amp;nbsp;You don't say whether all of the text files have the same format -- it would be good if they do, as that will make things much easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code might look something like this...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename fromzip zip 'c:\temp\class.zip';
data contents(keep=memname isFolder);
 length memname $200 isFolder 8;
 fid=dopen("fromzip");
 if fid=0 then
  stop;
 memcount=dnum(fid);
 do i=1 to memcount;
  memname=dread(fid,i);
  /* check for trailing / in folder name */
  isFolder = (first(reverse(trim(memname)))='/');
  output;
 end;
 rc=dclose(fid);
run;

options source2;
filename sasprog temp;
data _null_;
 file sasprog;
 length line $ 100;
 set contents(keep=memname);
 lines = 'data in; infile intxt(' || memname || '); input; put _infile_; run;';
 put 'filename intxt ZIP "c:\temp\class.zip";' ;
 put line;
 put 'filename intxt clear;';
run;

%include sasprog;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 May 2016 04:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/unzip-files-with-certain-extension/m-p/269097#M7470</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-05-09T04:00:24Z</dc:date>
    </item>
  </channel>
</rss>

