Naga Vemprala
Naga Vemprala

Reputation: 728

SAS: Reading datalines and data from a dataset together in DATA step

We will be getting a series of high profile order codes during peak hour of the day at 9 am till 10 AM. All the orders are captured into a permanent dataset ORDERS. Now we have to set the priority order to 1 for only the high profile orders.

I am capturing the 5 intervals of an hour and the corresponding high profile code during that hour using below code:

data orders; 
input time PROF_CODE $ ;
datalines;
900 A1 
936 R2 
948 BQ 
960 AJ
900 CT 
936 A1 
936 R2 
924 BQ 
900 AJ
912 CT  
;

data profile_orders; 
set orders;
array profile_code {900:960, 5} _temporary_; 
array HPC_CODE{5} $ _temporary_ ('AJ', 'BQ', 'CT', 'A1', 'R2');

do i = 900 to 960 by 12 ;
    do j = 1 to 5 by 1 ;
        if _n_ = 1 then
        input profile_code(i,j) @;
    end;
end;
drop i j; 

datalines;
5 8 3 7 11 
6 44 54 88 1
4 7 3 77 9
3 4 3 4 9 
91 3 8 0 12 
;

I have a dataset with order time, code and order details. I have to set the proriry flag only for the orders that came during this time and having the code matching from the permanent dataset and from the datalines above. Can I read the permanent dataset from the above data step itself along with the datalines? This order of codes changes everyday which we get in email. So we want to read the codes from datalines only.

Array values: profile_code --> (900,1) :5, (900,2) : 8, (900,3) :3, (900,4) : 7, (900,5) :11 (912,1) :6, (912,2) : 44, (912,3) :54, (912,4) : 88, (912,5) :1 (924,1) :4, (924,2) : 7, (924,3) :3, (924,4) : 77, (924,5) :9 (936,1) :3, (936,2) : 4, (936,3) :3, (936,4) : 4, (936,5) :9 (948,1) :91, (948,2) : 3, (948,3) :8, (948,4) : 0, (948,5) :12

Expected output:

910 A1 7 936 R2 9 948 BQ 4 960 AJ . . .

(I have rounded the time intervals to the nearest 12th minute interval in the input dataset orders).

Upvotes: 0

Views: 257

Answers (1)

Reeza
Reeza

Reputation: 21274

This will read datelines and the dataset, however the output may not be what you want.

data want;
set sashelp.class;
input name2 $ age2;
cards;
Sigma 13
Beta 14
Alpha 18
;
run;

Upvotes: 1

Related Questions