BookmarkSubscribeRSS Feed
pscott
Calcite | Level 5

I have a table that loops kinda like below only with every combination of those three variables. And I would like to create a report based on every horizonal Column of that table E.g. one report would where comany = next, serial # = 965465, Tech= Superman and another where company = next , serial # = 56465, Tech = Jed.I'm not sure the best way to do this but I tried this and it failed. 

 

data MacSerial2;
set MacSerial2;
do i= 1 to 5;
%let Tech = Tech[i]
%let targetno2 = serial#[i]
%let targetno3 = company[i]

end;
run;

 

 

CompanySerial #Tech
Next965465Superman
Next56465Jed
Google2463Jed
Google1583Justice
Matt15612bad
5 REPLIES 5
Astounding
Opal | Level 21

Without question, the best way would be to produce a report based on just the first observation.  Once you have that working, you can worry about how to extend that to additional observations.  The reporting requirements will dictate the methods you use to generate multiple reports.

pscott
Calcite | Level 5
Yes I have the report working properly I just need the variables to work properly!
Astounding
Opal | Level 21

OK, since we're talking without specifics here, this would be one way:

 

data _null_;

set macserial2;

call execute( ... statements that would generate a report for a single observation ...);

run;

 

That approach generates the reporting statements for each observation individually.  There might be other ways, such as using a BY variable instead.  And note that CALL EXECUTE does have its tricky points if any macro language is involved. 

ballardw
Super User

Please explain what this is supposed to do?

data MacSerial2;
set MacSerial2;
do i= 1 to 5;
%let Tech = Tech[i]
%let targetno2 = serial#[i]
%let targetno3 = company[i]

end;
run;

 

It would help to provide a couple rows of input data and what you expect to happen with that input.

Reeza
Super User

@pscott wrote:

I have a table that loops kinda like below only with every combination of those three variables. And I would like to create a report based on every horizonal Column of that table E.g. one report would where comany = next, serial # = 965465, Tech= Superman and another where company = next , serial # = 56465, Tech = Jed.I'm not sure the best way to do this but I tried this and it failed. 

 


I have no idea what this means. Post an example please, you'll get an answer much faster.

 

For example, what are you defining as a report? Is that a sheet in Excel, a PDF page, a single Excel file and one for each company, or a single PDF file for each?  And what do you mean with the variable = (company=next...), are they printed across, or down or sideways...literally no clue with what you've stated here. 

 

You're using arrays incorrectly and mixed with macro's, which doesn't make sense in your sample code.  Help us help you by detailing your question. 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 794 views
  • 0 likes
  • 4 in conversation