<?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 How to import the name of all .png/jpeg files in a folder? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960470#M374592</link>
    <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;In the past I could import all .txt format files name into a dataset using the below code.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename have pipe 'dir /b /s "myfolder\*.txt" ';
data want;
   infile have truncover;
   input filename $300.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I wonder if there is a similar technique for listing&amp;nbsp; .png files.&lt;BR /&gt;&lt;BR /&gt;Actually,&amp;nbsp;I have around 200 .png files that I need to import into rtf file. Each file ends with "eCDF.png" or "ePDF.png". Without reading all files name using SAS, I will need to type in every single time which is very time consuming.&amp;nbsp;&lt;BR /&gt;Appreciate your guidance and tips!&lt;/P&gt;</description>
    <pubDate>Thu, 27 Feb 2025 21:23:57 GMT</pubDate>
    <dc:creator>A_Kh</dc:creator>
    <dc:date>2025-02-27T21:23:57Z</dc:date>
    <item>
      <title>How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960470#M374592</link>
      <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;In the past I could import all .txt format files name into a dataset using the below code.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename have pipe 'dir /b /s "myfolder\*.txt" ';
data want;
   infile have truncover;
   input filename $300.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I wonder if there is a similar technique for listing&amp;nbsp; .png files.&lt;BR /&gt;&lt;BR /&gt;Actually,&amp;nbsp;I have around 200 .png files that I need to import into rtf file. Each file ends with "eCDF.png" or "ePDF.png". Without reading all files name using SAS, I will need to type in every single time which is very time consuming.&amp;nbsp;&lt;BR /&gt;Appreciate your guidance and tips!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 21:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960470#M374592</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-02-27T21:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960472#M374594</link>
      <description>&lt;P&gt;Can you post the code you are using to import one .png to an rtf file?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have that code working, then there are plenty of macros that can give you a list of all .png files in a directory.&amp;nbsp; e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0js70lrkxo6uvn1fl4a5aafnlgt.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0js70lrkxo6uvn1fl4a5aafnlgt.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you have working code for one .png file, you could use a macro to loop over a list of .png files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 21:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960472#M374594</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-02-27T21:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960473#M374595</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;,&amp;nbsp; thank you for your input!&lt;BR /&gt;Sure. The below is the way I'm importing images into rtf file. I would use macro loop once I figure out to list all files in the study folder/subfolders...&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods escapechar='^';
ods options nodate orientation=landscape; 
ods rtf file="C:\Desktop\test rtf.rtf" contents=yes toc_data ;

	ods rtf text='^S={outputwidth=100%  postimage="C:\myfolder\myfile-ecdf.png" just=c}  {\tc\f3\fs0\cf8 Table 1. myfile - eCDF}';

	ods rtf text='^S={outputwidth=100%  postimage="C:\myfolder\myfile-epdf.png" just=c}  {\tc\f3\fs0\cf8 Table 2.myfile - ePDF}';

ods rtf close; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I had also checked the source you referred and didn't see any info about .png extension.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 22:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960473#M374595</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-02-27T22:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960474#M374596</link>
      <description>Did you try changing *.txt to *.png?</description>
      <pubDate>Thu, 27 Feb 2025 22:19:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960474#M374596</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-02-27T22:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960475#M374597</link>
      <description>&lt;P&gt;Actually, I figured it out.&amp;nbsp;&lt;BR /&gt;Looks like the windows system doesn't resolve macro variable when used in FILENAME with PIPE.&amp;nbsp;&lt;BR /&gt;I replaced the macro variable &amp;amp;user with username and the code worked.&amp;nbsp; My apologies for hiding that crucial part of the problem in my first post.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename have pipe 'dir /b /s "C/&lt;FONT color="#FF0000"&gt;&amp;amp;user&lt;/FONT&gt;/myfolder\*.png" ';
data want;
   infile have truncover;
   input filename $300.;
run;


filename have pipe 'dir /b /s "C/&lt;FONT color="#008000"&gt;&lt;STRONG&gt;username&lt;/STRONG&gt;&lt;/FONT&gt;/myfolder\*.png" ';
data want;
   infile have truncover;
   input filename $300.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 22:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960475#M374597</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-02-27T22:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960476#M374598</link>
      <description>&lt;P&gt;Great.&amp;nbsp; The only reason it's not resolving the macro name is because you have the whole string (starting with dir) inside single quotes.&amp;nbsp; SAS will only resolve macro variables in double quotes (or no quotes at all).&amp;nbsp; You'd have to do something a little trickier to get that particular thing to work with a macro variable, but probably just easier to hardcode your user name unless this really needs to be dynamic.&lt;/P&gt;
&lt;P&gt;It might work just like this (assuming no spaces in your file path):&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename have pipe "dir /b /s C/&amp;amp;user/myfolder\*.png";&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 Feb 2025 23:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960476#M374598</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-02-27T23:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960479#M374601</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223320"&gt;@quickbluefish&lt;/a&gt;&amp;nbsp;, thank you for the feedback!&lt;BR /&gt;I believe eliminating the quote around the path also causes an issue, and I'm aware of the double quote standard for macro variables.&amp;nbsp; I still think that "dir command" doesn't read macro variable as SAS does.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 23:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960479#M374601</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-02-27T23:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960481#M374603</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321371"&gt;@A_Kh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223320"&gt;@quickbluefish&lt;/a&gt;&amp;nbsp;, thank you for the feedback!&lt;BR /&gt;I believe eliminating the quote around the path also causes an issue, and I'm aware of the double quote standard for macro variables.&amp;nbsp; I still think that "dir command" doesn't read macro variable as SAS does.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the outermost quotes are double quotes then the macro processor will resolve any macro variable within the quoted string BEFORE any other commands execute. The dir command will "see" the path with the resolved macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The challenge is that if your windows path contains blanks then the path itself needs also to be in double quotes for the dir command (and not single quotes).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't test it but at least one of below two options should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* option 1 */
filename myfile pipe %bquote(dir /b /s "C:\&amp;amp;user\myfolder\*.png");

/* option 2 */
filename myfile pipe "dir /b /s ""C:\&amp;amp;user\myfolder\*.png""";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then there is of course also the option to use SAS functions only for the directory listing which has the advantage that the same code will work for Windows and Unix environments and also with NOXCMD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 00:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960481#M374603</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-02-28T00:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960494#M374610</link>
      <description>&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path= c:\temp ;  /*the pathname to store the PNG files*/

data fname;
rc=filename('x',"&amp;amp;path");
did=dopen('x');
do i=1 to dnum(did);
 fname=dread(did,i);
 if upcase(scan(fname,-1,'.'))='PNG' then output;  /*Only output .png files*/
end;
did=dclose(did);
run;



%macro print_png(fname=,title=);
title j=l "&amp;amp;title.";
proc report data=x nowd noheader style={outputwidth=100% } ;
column x ;
define x/display;
compute x;
call define('x','style','style={ preimage="&amp;amp;path.\&amp;amp;fname." bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
endcomp;
run;
%mend;

ods _all_ close;
ods rtf file="&amp;amp;path.\want.rtf" style=minimal dpi=300 startpage=no bodytitle;
data x;
x=' ';output;
run;
title;
data _null_;
set fname;
call execute(catt('%nrstr(%print_png)(fname=',fname,',title=', catx(' ','Table',_n_) ,')'));
run;
ods rtf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1740708059099.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105017i04DD05EBB914B88C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1740708059099.png" alt="Ksharp_0-1740708059099.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 02:01:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960494#M374610</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-28T02:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960495#M374611</link>
      <description>&lt;P&gt;Also could try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myfile pipe %sysfunc(quote(dir /b /s "C:\&amp;amp;user\myfolder\*.png"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Feb 2025 02:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960495#M374611</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-28T02:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960496#M374612</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for guidance! &lt;BR /&gt;Yes, I've multiple blanks in the path, and the path is long enough. The second option worked for me. I've not seen before that spaces in the pathname cause a problem. I use the same path in my everyday work, looks like when path is nested in another pair of quotes, spaces make difference.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 02:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960496#M374612</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-02-28T02:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960497#M374613</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for tips!&amp;nbsp;&lt;BR /&gt;This also worked, but looks like it reads only one folder. Is there a workaround of this way to read all subfolders as well?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 02:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960497#M374613</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-02-28T02:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960498#M374614</link>
      <description>&lt;P&gt;This worked perfectly!&lt;/P&gt;
&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 03:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960498#M374614</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-02-28T03:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to import the name of all .png/jpeg files in a folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960499#M374615</link>
      <description>I remember &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;  has such a marco to read all subfolders.&lt;BR /&gt;You also could use command "dir *.png /s /b"  as you showd to get job done.</description>
      <pubDate>Fri, 28 Feb 2025 03:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-the-name-of-all-png-jpeg-files-in-a-folder/m-p/960499#M374615</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-28T03:39:15Z</dc:date>
    </item>
  </channel>
</rss>

