BookmarkSubscribeRSS Feed
Ranjeeta
Pyrite | Level 9

 

data stroke_onset;
set EVT.stroke_ischemic;
by HCN REG_TM;
where REG_TM <= ADM_TM;
if last.HCN;
Window1=(REG_TM-SP340_ONSET)/60;
length cat $100.;
if 0<=Window1<360 then cat="0to6";
else if 360<=Window1<2880 then cat="6to48";
else if 2880<=Window1<7200 then cat = ">=48";
else if missing (SP340_ONSET) then cat = "onset time missing";
else if SP340_ONSET>= REG_TM then cat = "Stroke onset equal to and after Reg time";
else cat='NA';
run;

I get the following error message 

Please advise

 

ERROR: BY variables are not properly sorted on data set EVT.STROKE_ISCHEMIC.
HCN=0132045842 CIHI_KEY_NACRS=539852017100006511 CIHI_KEY_DAD=5144420171005013
REG_TM=16JAN2018:16:49:00 ADM_TM=16JAN2018:17:44:00 DISCH_TM=19JAN2018:09:45:00
FIRST_ADM_TM=16JAN2018:16:49:00 FIRST_ADM_DT=16JAN2018 FIRST_INST=3985 FIRST_FAC=852
FIRST_FAC_NAME=St Michael's Hospital SP340_FIELD=YNN01160000N201801161430 SP340_TIME=201801161430
SP340_MON=JAN SP340_ONSET=16JAN2018:14:30:00 SP340_FLAG=1 SP340_VALID=1 DEATH_DT=.
STROKE_MORTALITY30=0 FIRST.HCN=1 LAST.HCN=1 FIRST.REG_TM=1 LAST.REG_TM=1 Window1=. cat= _ERROR_=1
_N_=68
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
40 at 2426:16
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 69 observations read from the data set EVT.STROKE_ISCHEMIC.
WHERE REG_TM<=ADM_TM;
WARNING: The data set WORK.STROKE_ONSET may be incomplete. When this step was stopped there were 62
observations and 21 variables.
WARNING: Data set WORK.STROKE_ONSET was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.85 seconds
cpu time 0.01 seconds

 

2 REPLIES 2
Reeza
Super User
You need to sort your data. Add a PROC SORT before this step and your BY statements in the two PROCS should match.

singhsahab
Lapis Lazuli | Level 10

Hello,

 

You have to sort your data first 

 

or

 

use Notsorted option with By statement. 

 

 

   by HCN REG_TM notsorted;

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 530 views
  • 0 likes
  • 3 in conversation