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;
Company | Serial # | Tech |
Next | 965465 | Superman |
Next | 56465 | Jed |
2463 | Jed | |
1583 | Justice | |
Matt | 15612 | bad |
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.
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.
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.
@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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.