Help using Base SAS procedures

Arrays

Reply
Occasional Contributor
Posts: 5

Arrays

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
Super User
Posts: 5,516

Re: Arrays

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.

Occasional Contributor
Posts: 5

Re: Arrays

Posted in reply to Astounding
Yes I have the report working properly I just need the variables to work properly!
Super User
Posts: 5,516

Re: Arrays

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. 

Super User
Posts: 11,343

Re: Arrays

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.

Super User
Posts: 19,855

Re: Arrays


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. 

Ask a Question
Discussion stats
  • 5 replies
  • 198 views
  • 0 likes
  • 4 in conversation