<?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 save attachments in a physical location of an object in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433462#M107463</link>
    <description>&lt;P&gt;Please post the complete code and log of the proc http step and the filename statement preceding it.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2018 10:29:37 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-02-02T10:29:37Z</dc:date>
    <item>
      <title>How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433418#M107450</link>
      <description>&lt;P&gt;Hi I want to get all attachments from SAS content server of solution EGRC 6.1 policy object and want to save it in a physical location on my server.&lt;/P&gt;&lt;P&gt;This is what I'm doing now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select BUSINESS_OBJECT_RK 
into: rk saperated by '-'
from sasoprsk.attachment_l
where BUSINESS_OBJECT_NM eq "POLICY_INST"
and   ATTACHMENT_TYPE_CD ne "LNK";

select FILE_NM 
into: file saperated by '-'
from sasoprsk.attachment_l
where BUSINESS_OBJECT_NM eq "POLICY_INST"
and   ATTACHMENT_TYPE_CD ne "LNK";

quit;


%macro attachment;

proc sql noprint;
select count(*) 
into: count
from sasoprsk.attachment_l
where BUSINESS_OBJECT_NM eq "POLICY_INST"
and   ATTACHMENT_TYPE_CD ne "LNK";
quit;

%do i = 1 %to &amp;amp;count;

filename out temp;

    %let rk_l=%scan(%bquote(&amp;amp;rk), %bquote(&amp;amp;i) ,%str(-));
    %let file_l=%scan(%bquote(&amp;amp;file), %bquote(&amp;amp;i) ,%str(-));

%put "file &amp;amp;file_l";
%put "http://sasbap.demo.sas.com/SASContentServer/repository/default/sasdav/Products/SASEnterpriseGRC/EnterpriseGRCMidTier6.1/Content/policy/&amp;amp;rk_l/&amp;amp;file_l"; 

proc http 
method="get"
url="http://sasbap.demo.sas.com/SASContentServer/repository/default/sasdav/Products/SASEnterpriseGRC/EnterpriseGRCMidTier6.1/Content/policy/&amp;amp;rk_l/&amp;amp;file_l"
webUserName="sas"
webPassword="Orion123"
out=out;
run;

%end;
%mend;  

%attachment;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I'm saving my attachment files in temp file but I want to save in a physical location as "C drive" inside a folder named as their rk of my object with proper extension as file.doc, file.xls or file.jpg etc.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;example 
obj_nm        rk      file_nm
POLICY_INST   12      file.xls
POLICY_INST   13      file.doc
POLICY_INST   14      file.gif&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to put those files as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;C:/12/file.xls 
C:/13/file.doc
C:/14/file.gif &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Kindly tell me how can I save my files from SAS content server to a physical location of my server with proper extension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 08:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433418#M107450</guid>
      <dc:creator>Azeem112</dc:creator>
      <dc:date>2018-02-02T08:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433435#M107452</link>
      <description>&lt;P&gt;You are, most likely, using sas on a server. That server is not able to access your local drives. You could try an UNC-path if the server sees your computer that should work. But using a network-share is recommended.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 09:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433435#M107452</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-02-02T09:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433437#M107454</link>
      <description>I want to place my files on the directory or server. I can access the server and get my files from server</description>
      <pubDate>Fri, 02 Feb 2018 09:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433437#M107454</guid>
      <dc:creator>Azeem112</dc:creator>
      <dc:date>2018-02-02T09:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433446#M107455</link>
      <description>&lt;P&gt;If you put files on a &lt;STRONG&gt;server&lt;/STRONG&gt; like this:&lt;/P&gt;
&lt;PRE&gt;C:/12/file.xls 
C:/13/file.doc
C:/14/file.gif&lt;/PRE&gt;
&lt;P&gt;where I am the admin, I'd come after you with a &lt;A href="http://www.catb.org/jargon/html/L/LART.html" target="_blank"&gt;LART&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;But it wouldn't happen, of course, because you wouldn't have write permission in the root directory anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why don't you simply make your filename dynamic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i = 1 %to &amp;amp;count;

  %let rk_l=%scan(%bquote(&amp;amp;rk), %bquote(&amp;amp;i) ,%str(-));
  %let file_l=%scan(%bquote(&amp;amp;file), %bquote(&amp;amp;i) ,%str(-));

  filename out "E:\somewhere_you_may_write_to\&amp;amp;rk_l.\&amp;amp;file_l.";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might also need to take care of instances where the path &amp;amp;rk_l does not yet exist.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 09:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433446#M107455</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-02T09:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433448#M107456</link>
      <description>&lt;P&gt;You wrote:&amp;nbsp; "&lt;SPAN&gt;I'm saving my attachment files in &lt;STRONG&gt;temp&lt;/STRONG&gt; file&amp;nbsp;..." -&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't see any assignment to a temp file in your code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you show where is that assignment - usually a FILENAME statement ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Just change the assignment to physical path and name you prefer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the program runs in the server - assign physical path in the server.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 09:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433448#M107456</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-02-02T09:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433450#M107457</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt; it's there:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i = 1 %to &amp;amp;count;

filename out temp;

    %let rk_l=%scan(%bquote(&amp;amp;rk), %bquote(&amp;amp;i) ,%str(-));
    %let file_l=%scan(%bquote(&amp;amp;file), %bquote(&amp;amp;i) ,%str(-));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;TBH, it also took me some time to find it. &lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 10:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433450#M107457</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-02T10:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433451#M107458</link>
      <description>I can't do this because in my drive there is not any folder of name as object_rk and this code is giving me HTTP client error because physical path didn't exist.</description>
      <pubDate>Fri, 02 Feb 2018 10:00:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433451#M107458</guid>
      <dc:creator>Azeem112</dc:creator>
      <dc:date>2018-02-02T10:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433453#M107459</link>
      <description>&lt;P&gt;If you want to write files to a server, you must of course make sure that the path exists and is writable by you. That's a very obvious given.&lt;/P&gt;
&lt;P&gt;To create such a path, you must talk with the server admin.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 10:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433453#M107459</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-02T10:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433454#M107460</link>
      <description>I want to create path using my code.</description>
      <pubDate>Fri, 02 Feb 2018 10:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433454#M107460</guid>
      <dc:creator>Azeem112</dc:creator>
      <dc:date>2018-02-02T10:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433457#M107461</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163076"&gt;@Azeem112&lt;/a&gt; wrote:&lt;BR /&gt;I want to create path using my code.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Look at the fcreate() data step function.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 10:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433457#M107461</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-02T10:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433461#M107462</link>
      <description>I managed to create my path using code but I'm still having issues as there is not any file having same name as file_nm. so proc HTTP gives error because he can't place incoming data from SAS content server to a file.</description>
      <pubDate>Fri, 02 Feb 2018 10:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433461#M107462</guid>
      <dc:creator>Azeem112</dc:creator>
      <dc:date>2018-02-02T10:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433462#M107463</link>
      <description>&lt;P&gt;Please post the complete code and log of the proc http step and the filename statement preceding it.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 10:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433462#M107463</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-02T10:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433466#M107464</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW the function is dcreate() - to create a directry/subdirectory (not fcreate);&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 10:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433466#M107464</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-02-02T10:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to save attachments in a physical location of an object in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433470#M107466</link>
      <description>&lt;P&gt;This is my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i = 1 %to &amp;amp;count;

*filename out temp;

%let rk_l=%scan(%bquote(&amp;amp;rk), %bquote(&amp;amp;i) ,%str(-));
%let file_l=%scan(%bquote(&amp;amp;file), %bquote(&amp;amp;i) ,%str(-));

options dlcreatedir;
libname newdir "C:/attachments/&amp;amp;rk_l";

filename out "C:/attachments/&amp;amp;rk_l/&amp;amp;file_l";


%put "file &amp;amp;file_l";
%put "http://sasbap.demo.sas.com/SASContentServer/repository/default/sasdav/Products/SASEnterpriseGRC/EnterpriseGRCMidTier6.1/Content/policy/&amp;amp;rk_l/&amp;amp;file_l"; 

proc http 
method="get"
url="http://sasbap.demo.sas.com/SASContentServer/repository/default/sasdav/Products/SASEnterpriseGRC/EnterpriseGRCMidTier6.1/Content/policy/&amp;amp;rk_l/&amp;amp;file_l"
webUserName="sas"
webPassword="Orion123"
out=out;
run;

%end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for help, this code is working fine.&lt;/P&gt;&lt;DIV class="adL"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 02 Feb 2018 10:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-attachments-in-a-physical-location-of-an-object-in/m-p/433470#M107466</guid>
      <dc:creator>Azeem112</dc:creator>
      <dc:date>2018-02-02T10:59:24Z</dc:date>
    </item>
  </channel>
</rss>

