<?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: Data step on many files with unique names and different variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984973#M43738</link>
    <description>&lt;P&gt;How do you know what formats to apply?&lt;/P&gt;
&lt;P&gt;You did not include any example code that was applying formats to variables in your original post.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Mar 2026 16:38:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2026-03-18T16:38:00Z</dc:date>
    <item>
      <title>Data step on many files with unique names and different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984960#M43735</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a folder where many files *.sas7bdat are stored. The files have different content in terms of variables and not a common prefix or suffix for mapping. So, they have unique names.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to perform the following in order to apply formats from a catalogue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=\...\;
libname mylib "&amp;amp;path.\myfiles";

options fmtsearch = (mylib .formats work);

data mydata; 
set mylib.mydatainput;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Formats and data are in the same folder (mylib).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since there are many files I would like not to do this job by reading file by file in data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using filename pipe ... but without success because files were not find.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me please?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2026 15:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984960#M43735</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2026-03-18T15:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Data step on many files with unique names and different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984968#M43736</link>
      <description>&lt;P&gt;I don't see what it is you are trying to accomplish.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Changing the FMTSEARCH option will tell SAS how to find the format definitions.&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;That should be all you need to do.&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you might need to do this for multiple libraries it might be best to remember the original setting of the option so you can reset it afterwards;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let old_fmtsearch=%sysfunc(getoption(fmtsearch));
libname mylib "mypath";
options insert=fmtsearch=(mylib.formats);
....
options fmtsearch=&amp;amp;old_fmtsearch;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The data step you posted is just making a copy of the dataset without doing anything at all about formats.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do that with PROC COPY without needing to specify the datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc copy inlib=mylib outlib=work mt=data;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Mar 2026 16:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984968#M43736</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-03-18T16:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Data step on many files with unique names and different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984972#M43737</link>
      <description>Thank you very much for your suggestions. I did not use proc copy because, contrary to the data step, it does not perform any data modification, which in this case is to apply data formats.</description>
      <pubDate>Wed, 18 Mar 2026 16:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984972#M43737</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2026-03-18T16:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Data step on many files with unique names and different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984973#M43738</link>
      <description>&lt;P&gt;How do you know what formats to apply?&lt;/P&gt;
&lt;P&gt;You did not include any example code that was applying formats to variables in your original post.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2026 16:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984973#M43738</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-03-18T16:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Data step on many files with unique names and different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984974#M43739</link>
      <description>I really do not know because only the catalogue was passed to me and the instructions you read were given. I have no access to other codes.</description>
      <pubDate>Wed, 18 Mar 2026 16:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984974#M43739</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2026-03-18T16:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Data step on many files with unique names and different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984975#M43740</link>
      <description>&lt;P&gt;Use PROC CONTENTS to look at the datasets.&lt;/P&gt;
&lt;P&gt;Do the variables have any user defined formats attached to them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use PROC FORMAT to look at the format catalog.&lt;/P&gt;
&lt;P&gt;Are the formats that exist int eh format catalog the same as those attached to the vairables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If both are YES then all you need to do is add the format catalog to the FMTSEARCH option and SAS will use those formats when displaying the variable's values.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If both (or either) is NO then you will need to figure it out yourself.&lt;/P&gt;
&lt;P&gt;You might look at the set of values the formats can decode and then compare those to the set of values that appear in the dataset for the different variables.&amp;nbsp; For example say you have format named YESNO that displays 1 as "YES" and 0 as "NO".&amp;nbsp; And you have variable named PRESENT that only has the values 0 and 1.&amp;nbsp; In that case you might deduce (quess) that you should attach the YESNO format to PRESENT.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2026 17:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984975#M43740</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-03-18T17:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Data step on many files with unique names and different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984986#M43743</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134532"&gt;@NewUsrStat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I really do not know because only the catalogue was passed to me and the instructions you read were given. I have no access to other codes.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is a step that you may want to add to this process. SAS Catalogs are usually version dependent. That means that it is possible that an upgrade to SAS will make the current catalog unreadable. Once you have that catalog responding to the FMTSEARCH option you may want to us Proc format to create a data set of the format definitions using the CNTLOUT option. Then at a later date you can rebuild the catalog for a different version using Proc Format and the CNTLIN option pointing to that data set. Having the data set may also be helpful to answer questions about the actual behavior of the formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc format library=somelib cntlout=alib.formatcontrol;
run;&lt;/PRE&gt;
&lt;P&gt;For example will read the catalog named FORMATS, the default name for a format catalog, in the library that has been defined on your system as Somelib and write the contents to a data set named Formatcontrol in the library defined on your system named Alib.&amp;nbsp; You likely want to write the data set into library other than work for later use. The exact library is up to you.&lt;/P&gt;
&lt;P&gt;To recreate the formats use:&lt;/P&gt;
&lt;PRE&gt;proc format library=thatlib cntlin=alib.formatcontrol;
run;&lt;/PRE&gt;
&lt;P&gt;The above code will create the formats in the library named Thatlib, which would need to be added to the FMTSEARCH path to be usable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suggestion: I would provide such a control data set and the proc format code instead of catalogs. That way things like operation system dependencies and versions are minimized.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2026 20:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-step-on-many-files-with-unique-names-and-different/m-p/984986#M43743</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2026-03-18T20:10:41Z</dc:date>
    </item>
  </channel>
</rss>

