BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Saranya_Sub
Obsidian | Level 7

Hi,

 

  i have around 10 XML file in a folder ,i have to loop through each of the XML and create SAS Dataset , sequentailly am doing it and the output is good.Now i have run the same macro for 10 XML file in parallel.10 sessions has to be created.

 

am not sure how to do the same. can any one guide me in doing that .

 

Thanks,

Saran.

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

Hi @Saranya_Sub,

 
let me share this little step-by-step "quasi" tutorial+macro for parallel processing in SAS I did some time ago (in advance I apologise for any spelling/grammar issues :-). Maybe you will find it useful.
 
 
All the best
Bart
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

5 REPLIES 5
ed_sas_member
Meteorite | Level 14

Hi @Saranya_Sub 

 

Could you please show your code so that we can help you?

Saranya_Sub
Obsidian | Level 7

%MACRO XML_Parse(_dir=);
filename dir "&_dir";
data work.dir;
length name $100;
d=dopen("dir");
num=dnum(d);
retain count 0;
do i=1 to num;
name=dread(d,i);
r=index(name,".xml");

if r ne 0 then
do;
call symput('XMLNAME'||left(i), scan(name,1,'.'));
output;
end;
end;

proc sql;

select count(*) INTO :_totalxml from work.dir;
quit;


%LET _totalxml=&_totalxml;

%do _XMLLOOP = 1 %TO &_totalxml;

filename xmlfile "&_dir.&_XMLNAME..xml";
filename mapfile "&_dir.&_XMLNAME..map";
libname xmlfile xmlv2 xmltype=xmlmap xmlmap=mapfile automap=replace;


---CODE TO JOIN ALL THE TABLES USING THE ORIDIANL COLUMN TO BRING TO ONE TABLES

%END;

%MEND;
%XML_Parse(_dir='/ccc/ccc/cc');

 

This code will read each of the XML file ,when first XML processing is completed it moves to the next one.

now my question is is there any way to run the macro in parallel so that i can read all the process all the XML file in same time 

Sequential(above code)

XML 1             Parallel( i want it in this way)

XML 2   --- >  XML 1 XML 2 XML 3 

XML 3  

 

though there are some document in the web ,am not able to understand clearly.

 

Please help

 

Thanks,

Saran

unison
Lapis Lazuli | Level 10

Take a look to see if anything in this thread solves your problem: https://communities.sas.com/t5/General-SAS-Programming/Macros-and-Parallel-processing/td-p/430028

 

-unison

-unison
SASKiwi
PROC Star

In my experience using SAS/CONNECT is the easiest and most reliable way to do this within SAS code. If you don't have this product then that rules out this option.

yabwon
Onyx | Level 15

Hi @Saranya_Sub,

 
let me share this little step-by-step "quasi" tutorial+macro for parallel processing in SAS I did some time ago (in advance I apologise for any spelling/grammar issues :-). Maybe you will find it useful.
 
 
All the best
Bart
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1107 views
  • 3 likes
  • 5 in conversation