For each record in test(dataset) we have to create five records in new dataset(final)
ex:in test(dataset) 1st record
Account Milestone Period
SDI 2011Q2
Based on test(dataset) we have to create another dataset Final(dataset) with 5 records.
Account Milestone Period Measurement
SDI 2011 Q2 Approval Rate
SDI 2011 Q2 Days to Approval
SDI 2011 Q2 Fulfillment Rate
SDI 2011 Q2 Days to Ship
SDI 2011 Q2 Compliance
We have to repeat this all records in dataset(test).Can someone suggest me how to do this?
Thanks,
sk
/* Create the original dataset for testing */
Data original;
input Account:$3. Milestone Period:$2.;
datalines;
SDI 2011 Q2
run;
/* Create a simple dataset with the 5 unique measurement observations */
Data Measures;
infile datalines truncover;
input Measurement $ 1-25;
datalines;
Approval Rate
Days to Approval
Fulfillment Rate
Days to Ship
Compliance
;
run;
/* Do the actual work */
/* A cartesian join is perfect for this */
proc sql;
create table final as
select *
from original, measures
;
quit;
data test;
length Account Milestone_Period $20;
account = 'SDI';
milestone_period = '2011 Q2';
output;
account = 'SDII';
milestone_period = '2011 Q3';
output;
run;
data final;
length Measurement $50;
set test;
array test {5} $50 _temporary_ ('Approval Rate','Days to Approval','Fulfillment Rate','Days to Ship','Compliance');
do i = 1 to 5;
measurement = test(i);
output;
end;
drop i;
run;
proc print; var account milestone_period measurement; run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.