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
PROC Star

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
PROC Star

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.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 965 views
  • 0 likes
  • 4 in conversation