BookmarkSubscribeRSS Feed
brm
Calcite | Level 5 brm
Calcite | Level 5

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

2 REPLIES 2
SASJedi
SAS Super FREQ

  /* 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;

Check out my Jedi SAS Tricks for SAS Users
NickR
Quartz | Level 8

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;

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!

How to Concatenate Values

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.

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
  • 2 replies
  • 4084 views
  • 1 like
  • 3 in conversation