<?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 call a sas7bdat file directly without referring the directory as the library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717711#M221984</link>
    <description>&lt;P&gt;Hi all SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally we assign the library as a folder containing the file we want to call. However, I did a search and see if there is any way to call the file directly.&lt;/P&gt;
&lt;P&gt;And from this&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Studio/How-do-I-import-a-sas7bdat-file-to-SAS-studio-and-then-save-it/td-p/558844#:~:text=sas7bdat%20is%20already%20a%20SAS,statement%2C%20or%20in%20proc%20sql." target="_self"&gt;forum discussion&lt;/A&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; has said&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;So if you have a file name 'mydata.sas7bdat'&amp;nbsp; (note that the filename MUST be in all lowercase letters as SAS is running in Unix environment where filenames are case sensitive) then you code could look like:&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;libname mylib '/folders/myfolders';
proc contents data=mylib.mydata; run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc contents data="/folders/myfolders/mydata.sas7bdat"; run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have two questions:&lt;/P&gt;
&lt;P&gt;1. Is it strict that we must set the name of the sas7bdat in lowercase ?&lt;/P&gt;
&lt;P&gt;2. Regarding how to access the file sas7bdat directly as mention above, when I run proc contents&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc contents data="/folders/myfolders/mydata.sas7bdat"; run;​&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS just showed me the information of the variables in this file, not the dataset, can you please tell me how to access the dataset directly without referring the directory?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P/S: I also try this code to access the file directly but SAS cannot import properly&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	infile "C:\Users\pnguyen\Desktop\New folder\winsorize.sas7bdat"; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;output dataset "test" from SAS&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1612811461568.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54481i36030E3A16584339/image-size/medium?v=v2&amp;amp;px=400" role="button" title="My97_0-1612811461568.png" alt="My97_0-1612811461568.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Feb 2021 19:11:48 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2021-02-08T19:11:48Z</dc:date>
    <item>
      <title>How to call a sas7bdat file directly without referring the directory as the library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717711#M221984</link>
      <description>&lt;P&gt;Hi all SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally we assign the library as a folder containing the file we want to call. However, I did a search and see if there is any way to call the file directly.&lt;/P&gt;
&lt;P&gt;And from this&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Studio/How-do-I-import-a-sas7bdat-file-to-SAS-studio-and-then-save-it/td-p/558844#:~:text=sas7bdat%20is%20already%20a%20SAS,statement%2C%20or%20in%20proc%20sql." target="_self"&gt;forum discussion&lt;/A&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; has said&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;So if you have a file name 'mydata.sas7bdat'&amp;nbsp; (note that the filename MUST be in all lowercase letters as SAS is running in Unix environment where filenames are case sensitive) then you code could look like:&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;libname mylib '/folders/myfolders';
proc contents data=mylib.mydata; run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc contents data="/folders/myfolders/mydata.sas7bdat"; run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have two questions:&lt;/P&gt;
&lt;P&gt;1. Is it strict that we must set the name of the sas7bdat in lowercase ?&lt;/P&gt;
&lt;P&gt;2. Regarding how to access the file sas7bdat directly as mention above, when I run proc contents&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc contents data="/folders/myfolders/mydata.sas7bdat"; run;​&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS just showed me the information of the variables in this file, not the dataset, can you please tell me how to access the dataset directly without referring the directory?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P/S: I also try this code to access the file directly but SAS cannot import properly&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	infile "C:\Users\pnguyen\Desktop\New folder\winsorize.sas7bdat"; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;output dataset "test" from SAS&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1612811461568.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54481i36030E3A16584339/image-size/medium?v=v2&amp;amp;px=400" role="button" title="My97_0-1612811461568.png" alt="My97_0-1612811461568.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 19:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717711#M221984</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-08T19:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a sas7bdat file directly without referring the directory as the library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717712#M221985</link>
      <description>&lt;P&gt;You cannot reference &lt;STRONG&gt;any&lt;/STRONG&gt; file on a computer without specifying the directory.&amp;nbsp; You could potentially change the current working directory for the process that is running SAS and then use a relative path instead of an absolute path:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x "cd data=""/folders/myfolders/mydata"" ";
proc contents data="mydata.sas7bdat" ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but you are still specifying the directly implicitly by using a relative path.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note you do not need to add the .sas7bdat extension in the quoted physical name.&amp;nbsp; So if you used this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data="/folders/myfolders/mydata"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then SAS will add the .sas7bdat extension when it goes to look for the file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;1. Is it strict that we must set the name of the sas7bdat in lowercase ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;If your SAS code is running on Unix then the while filename part of the path (not the directory part) must be in all lowercase.&amp;nbsp; If the filename as has uppercase letters in it then SAS will just not find it since it will only look for the file with the lowercase letters in its name.&amp;nbsp; If SAS is running on Windows then case does not matter as Windows does not allow two different files have names that differ only in the case of the letters in the name.&amp;nbsp; So even if SAS did look for the lowercase filename Windows would return the one file with that name whether or not the name had any uppercase letters in it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;SAS just showed me the information of the variables in this file, not the dataset,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;That comment makes no sense.&amp;nbsp; The SAS dataset is the file.&amp;nbsp; The file is the dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;LI-CODE lang="sas"&gt;data test;
	infile "C:\Users\pnguyen\Desktop\New folder\winsorize.sas7bdat"; 
run;&lt;/LI-CODE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This dataset TEST does not have any variables nor any observations since you never defined any variables in the data step nor read in any data.&amp;nbsp; The INFILE statement is for pointing at files that you want to read with an INPUT statement, but your data step does not have an INPUT statement.&amp;nbsp; Even if it did have an INPUT statement it would not work as you probably want has a SAS dataset is not a text file to be read. It is complex binary structure.&amp;nbsp; That is why you need to use the SET (or MERGE or UPDATE or MODIFY) statement to reference it so that SAS knows to interpret that binary file as a SAS dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 19:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717712#M221985</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-08T19:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a sas7bdat file directly without referring the directory as the library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717716#M221988</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your explanation.&lt;/P&gt;
&lt;P&gt;So, back to the one that I confuse you&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;SAS just showed me the information of the variables in this file, not the dataset,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;That comment makes no sense.&amp;nbsp; The SAS dataset is the file.&amp;nbsp; The file is the dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;when I run this code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data="C:\Users\pnguyen\Desktop\New folder\winsorize.sas7bdat"; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS turns out a result about the information of &lt;STRONG&gt;winsorize&lt;/STRONG&gt; dataset. My question is how we refer to this dataset later on, for example, a proc means afterward?&lt;/P&gt;
&lt;DIV id="gtx-trans" style="position: absolute; left: 1104px; top: 251.913px;"&gt;
&lt;DIV class="gtx-trans-icon"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 08 Feb 2021 19:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717716#M221988</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-08T19:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a sas7bdat file directly without referring the directory as the library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717717#M221989</link>
      <description>&lt;P&gt;You can use the same syntax with any other place where you would reference a dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data="C:\downloads\class";&amp;nbsp;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice that under the hood SAS will actually create a libref that points to that directory. Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data="C:\downloads\class" out=contents; run;
proc print data=contents;
  var libname memname name type length ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs    LIBNAME     MEMNAME    NAME      TYPE    LENGTH

 1     WC000001     CLASS     Age         1        8
 2     WC000001     CLASS     Height      1        8
 3     WC000001     CLASS     Name        2        8
 4     WC000001     CLASS     Sex         2        1
 5     WC000001     CLASS     Weight      1        8
&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Now once you have referenced the file a specific libref will exist and you could use it to reference the dataset instead as long as you are in the same SAS session.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=WC000001.class;&amp;nbsp;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;But if you prefer to use the normal libname.memname syntax then it is better to write your own LIBNAME statement so that you have control over the libref that is used as there is not really anyway to know in advance what libref will be generated by using the quoted physical filename syntax.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;So use something like this instead:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mydata "C:\downloads" ;
proc contents data=mydata.class; 
run;
proc means data=mydata.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 19:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-a-sas7bdat-file-directly-without-referring-the/m-p/717717#M221989</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-08T19:59:25Z</dc:date>
    </item>
  </channel>
</rss>

