BookmarkSubscribeRSS Feed
Emma8
Quartz | Level 8
 
4 REPLIES 4
mkeintz
PROC Star

What is the rule you are using to assign ID's?  It is not apparent to me.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
jimbarbour
Meteorite | Level 14

Emma,

 

Are you trying to create the data contained in the third column as defined by the comma delimiter?  It appears to work just fine when I run it in Enterprise Guide.   See below.

 

Are you running in SAS Studio?  If you are running in SAS studio, make sure your data is all the way over hard against the left margin.   The first byte of data needs to start in position 1 with no indentation.

 

Jim

 

jimbarbour_0-1602731701224.png

 

mkeintz
PROC Star

@jimbarbour   I think the OP wants code to generate the NEWID from the prior two variables - which is why I asked for a rule.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
novinosrin
Tourmaline | Level 20
data have;
infile cards dsd;
input ID $ Datetime :datetime20.;* NEW_ID;
format datetime datetime20.;
cards;
AAC56,25AUG20:02:00:00,1
AAC56,27AUG20:21:00:00,2
AAC56,31AUG20:10:30:00,3
AAC56,02SEP20:20:00:00,4
AAC56,29SEP20:21:43:00,5
AAC56,29SEP20:21:43:00,5
AAC56,29SEP20:22:03:00,5
AAC56,29SEP20:23:03:00,5
AAC56,30SEP20:00:03:00,5
AAC56,30SEP20:01:03:00,5
AAC58,28SEP20:13:45:00,1
AAC58,29SEP20:15:00:00,2
AAC58,29SEP20:16:00:00,2
AAC58,29SEP20:16:00:00,2
AAC58,29SEP20:17:10:00,2
;

%let hour=1;/*Assign your interval here i.e. 1 or 2 etc*/
data want;
 do until(last.id);
  set have;
  by id;
  if first.id=1 or intck('hour',n,datetime)>&hour then new_id=sum(new_id,1);
  n=datetime;
  output;
 end;
 drop n;
run;

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
  • 4 replies
  • 526 views
  • 1 like
  • 4 in conversation