Hi Reeza,
The only remaining concern is that the program is able to output for only one county(but gave the result exaclty what I wanted). The program ignored remaining 101 counties. The macro resolution was perfect. Why is the do loop processing in the ods statement is limited to only one county(first county)?There is no warning/error in the log as well.
Thanks for helping me.
Have a good day
Both examples worked perfectly in my case - with names.
Post your code and check it over that it aligns with the sample code.
I only get multiple files. Are there errors in your log?
The NEWFILE method will not allow you to control the name, you'll need to use the macro version if you want county name.
No errors in the log. That's what I got. Attached is the partial output. I wanted CountyA, CountyB, CountyC etc. Inside each file, I got exactly what I wanted. Thanks
POST YOUR CODE AND LOG.
There are twp solutions provided, which did you use? I can't help debug something I can't see.
I got the result from the program without using the macro. With the macro program, I don't get solution.
Hello,
I have uploaded the partial data after changing some identifiers and making a little artificial. Ony six counties included. If we could produce six rtf flies such as AD.rtf, B/G.rtf, B/S.rtf,BA.rtf,Be.rtf, and BO.rtf then it will be same for 102 counties.
I appreciate your help.
Sorry, I don't download files.
Hello,
Thank you very much for helping me out. Finally , with a small change in your suggestion, I got the output that I wanted. Besides, I need to use %sysfunc in ods statement because some county names have '/' symbol and as a macro resolving values produce an extra '/ ' in the directory , so the an error came as "Physical file not found" for those counties with symbo '/'. with%Sysfunc options this will be solved. The code below should perfectly run. Awesome! I'm very happy. Will be in touch.
PROC SQL noprint ;
SELECT COUNT(DISTINCT COUNTYNAME) INTO : Nobs FROM QSSTOTAL;
SELECT DISTINCT COUNTYNAME INTO : NAME1-:NAME%LEFT(&Nobs) FROM QSSTOTAL;QUIT;
%let nobs=&sqlobs;
%macro output_all;
%DO i=1 %TO &Nobs;
%put Processing &&name&i;
proc sort data=QSStotal out=class1;
by countyname;
run;
ods rtf file="R:\H\COUNTY2016\%SYSFUNC(COMPRESS (&&&NAME&i,/,PS)).rtf"
newfile=bygroup;
title "County is &&&NAME&i ";
proc freq data=class1;
tables q1--q10;
where countyname="&&&NAME&i";
run;
ods rtf close;
%end;
%mend;
options mprint;
%output_all;
I'm glad that after all that help you marked your own answer as correct.
Cheers.
Hi Reeza,
Actually, the credit should go to you because you helped me a lot. Is there a way to redirect the credit to you. I was giving the credit to you but it appeared to my own post by accident. I didn't realize that. I was a first time user. I want to dedicate this to you. Sorry about that. It's not going to happen next time. My applogies.
I appreciate any idea to dedicate this credit to you.
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!
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.