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

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

 

Reeza
Super User

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.

 

 

kllamitarey
Obsidian | Level 7

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

rtfcountyfile.PNG

Reeza
Super User

POST YOUR CODE AND LOG.

 

There are twp solutions provided, which did you use? I can't help debug something I can't see.

kllamitarey
Obsidian | Level 7

I got the result from the program without using the macro. With the macro program, I don't get solution.

kllamitarey
Obsidian | Level 7

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.

Reeza
Super User

Sorry, I don't download files.

 

kllamitarey
Obsidian | Level 7

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;

Reeza
Super User

I'm glad that after all that help you marked your own answer as correct. 

Cheers.

kllamitarey
Obsidian | Level 7

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 24 replies
  • 1980 views
  • 0 likes
  • 3 in conversation