<?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: Wildcard? Macros? Macros with a wildcard? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784016#M81278</link>
    <description>&lt;P&gt;You can either use SCAN() to extract just the member name from the filename.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(cats('%sort(filename=',scan(filename,1,'.'),')'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or change the macro to accept a full dataset name instead of just a member name in the W libref.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro sort (dataset);

proc sort data=&amp;amp;dataset ;
by ID;
run;

%mend sort;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then you could pass in either W.MEMBER or just the quoted physical name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(cats('%sort(',quote(catx('\','C:\Users\Public\ABCDE\alldata',filename)),')'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you already have a libref pointing to the directory there is no need to look for &lt;STRONG&gt;files&lt;/STRONG&gt;.&amp;nbsp; Just look for &lt;STRONG&gt;datasets&lt;/STRONG&gt;.&amp;nbsp; In fact you should only look for datasets that have the ID variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname w 'C:\Users\Public\ABCDE\alldata';
proc sql;
create table members as
  select libname,memname
  from dictionary.columns
  where libname='W' and upcase(name)='ID'
  order by libname,memname
;
quit;
data _null_;
  set members;
  call execute(catx(' ','proc sort data=',catx('.',libname,memname),';by id;run;'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Dec 2021 21:02:05 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-12-03T21:02:05Z</dc:date>
    <item>
      <title>Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783717#M81267</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple sas transport files (.stc) that I am trying to import first into the sas data files (.sas7bdat). I am trying to use the macro to import all at once. However, my datafiles are named similar to sn55632-00001_blah-qwerty.stc,&amp;nbsp;sn55632-00002_blah-yuiop.stc,&amp;nbsp;sn55632-00003_blah-asdfg.stc, and so on. So, if you see the pattern here, the numbers after the first hypen are increasing by a unit. That's why I found somewhere that I could do 'mypath/sn55632-0000:.stc' (notice the colon there before .stc). However, it's not working for me for some reasons. Could anyone please guide me how I can go about it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 17:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783717#M81267</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-02T17:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783739#M81268</link>
      <description>&lt;P&gt;In SAS the colon is not a true wild card. It allows you to select variables that start with the text to the left of the colon. You can't use it in file names where you need to follow the OS file naming rules. There are other ways of doing what you want but you first need to post a working hard-coded version of your program.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 18:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783739#M81268</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-12-02T18:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783751#M81269</link>
      <description>&lt;P&gt;&amp;nbsp;I am working on this private data on a standalone device so I cannot really share exactly what I am doing. However, I can probably write the same code with different filenames to show here. What would be the relevant wildcard operator instead of colon in SAS as you mentioned?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 19:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783751#M81269</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-02T19:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783752#M81270</link>
      <description>&lt;P&gt;option nofmterr;&lt;/P&gt;&lt;P&gt;libname w 'C:\Users\Public\ABCDE\alldata';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro import (n);&lt;/P&gt;&lt;P&gt;filename transfile 'C:\Users\Public\ABCDE\alldata\&lt;SPAN&gt;sn55632-0000&lt;/SPAN&gt;&amp;amp;n.\:.stc';&lt;/P&gt;&lt;P&gt;proc cimport lib=w infile =tranfile;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend import;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%import (1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have right now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The filenames are similar to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sn55632-00001_blah-qwerty.stc&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;sn55632-00002_blah-yuiop.stc&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sn55632-00003_blah-asdfg.stc&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sn55632-00049_blah-asdfg.stc&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 19:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783752#M81270</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-02T19:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783757#M81271</link>
      <description>&lt;P&gt;Looks like you want to build the list of filename first.&lt;/P&gt;
&lt;P&gt;If you can run operating system commands then use that.&amp;nbsp; For example on unix you could use the ls command.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files;
  infile "ls /users/public/abdcde/alldata/*.stc" pipe truncover;
  input filename $200.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or for Window you might use the DIR command.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files;
  infile "c:; cd C:\Users\Public\ABCDE\alldata; dir /b *.stc" pipe truncover;
  input filename $200.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you might need to use DOPEN() and DREAD() commands instead to get the list of files.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files;
  rc=filename('dir', 'C:\Users\Public\ABCDE\alldata');
  did=dopen('dir');
  do index=1 to dnum(did);
    length filename $200;
   filename=dread(did,index);
   if 'stc'=scan(filename,-1,'.') then output;
  end;
  rc=dclose(did);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have the list of filenames use that to generate the code to process each STC file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What type of files are these STC files?&amp;nbsp; The STC extension has no fixed meaning.&amp;nbsp; If you don't know that they are take a look at the first few records in the file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'C:\Users\Public\ABCDE\alldata\*.stc' lrecl=80 recfm=f obs=5;
  input;
  list;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 19:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783757#M81271</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-02T19:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783767#M81272</link>
      <description>&lt;P&gt;Awesome. Thank you!&lt;/P&gt;&lt;P&gt;The 3rd block of code you provided worked great. I might still need some help looping through those names to import them as .sas7bdat files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 20:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783767#M81272</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-02T20:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783775#M81273</link>
      <description>&lt;P&gt;Use CALL EXECUTE with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro import (filename = );

proc cimport lib=w infile = "&amp;amp;filename";
run;

%mend import;

data files;
  rc=filename('dir', 'C:\Users\Public\ABCDE\alldata');
  did=dopen('dir');
  do index=1 to dnum(did);
    length filename $200;
   filename=dread(did,index);
   if 'stc'=scan(filename,-1,'.') then 
   call execute('%import(filename =' !! strip(filename) !! ');');
  end;
  rc=dclose(did);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Dec 2021 20:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/783775#M81273</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-12-02T20:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784003#M81276</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;. No doubt you all are Super User. I had never utilized the forum before. Well, I guess I am under the shadow of the legends.&lt;/P&gt;&lt;P&gt;Muchas Gracias!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 19:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784003#M81276</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-03T19:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784010#M81277</link>
      <description>&lt;P&gt;Further Question: I am using a similar method to sort the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;%macro sort (filename = );

proc sort data=w.&amp;amp;filename;
by ID;
run;

%mend sort;

data files;
  rc=filename('dir', 'C:\Users\Public\ABCDE\alldata');
  did=dopen('dir');
  do index=1 to dnum(did);
    length filename $200;
   filename=dread(did,index);
   if 'sas7bdat'=scan(filename,-1,'.') then 
   call execute('%sort(filename =' !! strip(filename) !! ');');
  end;
  rc=dclose(did);
run;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem with this is that the filename includes '.sas7bdat', and when it goes to proc sort, it'll throw an error because proc sort data=filename needs the filenames without extensions. How do I do it? I tried doing strip(filename-'.sas7bdat') to see if that's a thing but it didn't work either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 20:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784010#M81277</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-03T20:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784016#M81278</link>
      <description>&lt;P&gt;You can either use SCAN() to extract just the member name from the filename.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(cats('%sort(filename=',scan(filename,1,'.'),')'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or change the macro to accept a full dataset name instead of just a member name in the W libref.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro sort (dataset);

proc sort data=&amp;amp;dataset ;
by ID;
run;

%mend sort;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then you could pass in either W.MEMBER or just the quoted physical name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(cats('%sort(',quote(catx('\','C:\Users\Public\ABCDE\alldata',filename)),')'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you already have a libref pointing to the directory there is no need to look for &lt;STRONG&gt;files&lt;/STRONG&gt;.&amp;nbsp; Just look for &lt;STRONG&gt;datasets&lt;/STRONG&gt;.&amp;nbsp; In fact you should only look for datasets that have the ID variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname w 'C:\Users\Public\ABCDE\alldata';
proc sql;
create table members as
  select libname,memname
  from dictionary.columns
  where libname='W' and upcase(name)='ID'
  order by libname,memname
;
quit;
data _null_;
  set members;
  call execute(catx(' ','proc sort data=',catx('.',libname,memname),';by id;run;'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 21:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784016#M81278</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-03T21:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784017#M81279</link>
      <description>Wonderful. It worked like a charm! And thank you for pointing out the good programming practice out there.</description>
      <pubDate>Fri, 03 Dec 2021 21:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784017#M81279</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-03T21:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784026#M81280</link>
      <description>&lt;P&gt;Is it okay if I ask more questions &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;? I feel like I have been learning a lot this way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I have 134 datasets (now SAS datasets, thanks to you), all sorted within the same library. Now I need to merge them in two ways.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, I need to merge, them into four phases:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1st Phase: s12345_0001_ads_qwerty&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s12345_0049_ads_cvbnm&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2nd Phase: s6789_0001_ads2_dfghk&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s6789_0028_ads2_zxcvb&lt;/P&gt;&lt;P&gt;and so on.&lt;/P&gt;&lt;P&gt;If you see the pattern here, the first name before the underscore stays the same, while the number after the underscore increases by 1 throughout the phase.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly, I need to merge all 134 of them into one dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem with using similar macros, in this case, is I guess you have one filename passed to it at once, so SAS doesn't recognize what to merge. While with the SQL, I have hard time assigning dataname into the table, if that's the way.&lt;/P&gt;&lt;P&gt;Also, I have not used loops to run individual files through the merge statement yet.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 22:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784026#M81280</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-03T22:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784036#M81281</link>
      <description>&lt;P&gt;So each dataset has ID and some other set of distinct variables that have different names than the variables in the other similarly named datasets?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data s12345;
  merge w.s12345_: ;
  by id;
run;
data s6789;
  merge w:s6789_:;
  by id;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Are you sure don't want to SET them together instead of MERGEing them?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data s12345;
  set w.s12345_: indsname=indsname;
  by id;
  source=indsname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 23:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784036#M81281</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-03T23:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784042#M81282</link>
      <description>Yes. Each dataset has ID as a unique identifier. There are ~1400 observations altogether i.e. number of participants. 1st phase would have different datasets for different observations for 3 years on those participants.&lt;BR /&gt;2nd phase has those observations for another 3years for the same participants. Likewise for the 3rd and 4th phases.&lt;BR /&gt;So, if I set them, there will be 4(number of phases)*1400 observations = 6400 observations, while I only want 1400 observations.</description>
      <pubDate>Sat, 04 Dec 2021 00:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784042#M81282</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-04T00:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784047#M81283</link>
      <description>&lt;P&gt;If you have 4 years of data for 1,400 subjects then you SHOULD have 4*1,400 = 6,400 observations.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 03:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784047#M81283</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-04T03:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784373#M81292</link>
      <description>Right. However, it's the data for the same participants over four years. So, based on my understanding, I will have more variables/columns for the same 1400 participants. Please correct me if I am wrong, or suggest to me what you think is efficient.&lt;BR /&gt;Thank you!</description>
      <pubDate>Mon, 06 Dec 2021 19:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784373#M81292</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-06T19:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784383#M81293</link>
      <description>&lt;P&gt;We cannot tell without seeing how your study is setup.&lt;/P&gt;
&lt;P&gt;Normally if you are asking the same questions the values should be stored into the same variable. If the question is different then it will require a different variable.&amp;nbsp; For example if you ask their weight in the first wave/year and again in the follow-up years then you should store that into the same variable and have different observations for the separate wave/year.&amp;nbsp; But if you asked their change from baseline weight that would be a different variable and only apply to the the follow-up waves and not the initial wave.&amp;nbsp; So the variable will have a missing value for the observation that represents the wave where it does not apply.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 20:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784383#M81293</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-06T20:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784389#M81294</link>
      <description>Makes sense. It seems like I will have to SET then as it matches your first scenario. Well basically, I have four waves, and within those waves, the same variable is calculated 5 to 6 times at different periods of time.</description>
      <pubDate>Mon, 06 Dec 2021 20:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784389#M81294</guid>
      <dc:creator>Sudeep_Neupane</dc:creator>
      <dc:date>2021-12-06T20:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard? Macros? Macros with a wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784392#M81295</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/408621"&gt;@Sudeep_Neupane&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Makes sense. It seems like I will have to SET then as it matches your first scenario. Well basically, I have four waves, and within those waves, the same variable is calculated 5 to 6 times at different periods of time.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Depending on how it is stored you might have a series of variables.&amp;nbsp; X1 - X6 for example. Or you might have multiple observations per wave with the time period as a secondary key variables.&amp;nbsp; But that is probably not how it is currently setup based on the observation counts you provided before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can always convert from one structure to another structure depending on your reporting/analysis needs.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 20:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard-Macros-Macros-with-a-wildcard/m-p/784392#M81295</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-06T20:43:22Z</dc:date>
    </item>
  </channel>
</rss>

