BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rich93johnson
Fluorite | Level 6

Thanks to both of you!!!!!! I believe either solution will work. I will try and integrate. 

Tom
Super User Tom
Super User

Can you post sample data (preferable for a simplified version).  Also not as an XSLX file. The XLSX you attached is not viewable in the forum (perhaps it is too large or uses Excel features the viewer doesn't support).  Many people cannot download documents.

 

Make a simple example using "lags" of just 2 or 3 to get the idea across, not hundreds. Post the data as a data step.  Show what results you expect.

 

Did the code generation @Patrick posted not work for you?  Why are you trying to get SQL to generate the code instead?  Is the code you want to generate small enough to fit in a single macro variable?  A single macro variable on only hold 65K characters.

Patrick
Opal | Level 21

Below creates sample data very close to what the Proc Import creates when run for the attached Excel sample data.

data LOOP_SAMPLE;
  FORMAT
    Item BEST12.
    Date DATE9.
    Loc  $CHAR4.
    Qty  BEST12.
    RLT  BEST12.;
  call streaminit(12345);
  do date='03oct2016'd to '12jan2020'd;
    do item=1 to 3;
      do loc='DDSP','DDCN','DDCT';
        if loc='DDSP' then rlt=20;
        else if loc='DDCN' then rlt=40;
        else rlt=20;
        qty=ceil(rand('uniform',0,999));
        output;
      end;
    end;
  end;
  stop;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 17 replies
  • 4982 views
  • 3 likes
  • 3 in conversation