have input dataset like
DATA K;INPUT city:$ ;DATALINES;aaaaabbb;RUN;
i need output like
DATA r;
set k;
city seq;a 1a 1a 1a 1a 1b 2b 2b 2;RUN;
If your data is sorted by city, then simply do
data r; set k; by city; if first.city then seq+1; run;
If not then do
data r; if _n_=1 then do; dcl hash h(); h.defineKey ("city"); h.defineData ("seq"); h.defineDone (); end; set K; if h.find() ne 0 then do; seq+1;h.add(); end; run;
April 27 - 30 | GAYLORD TEXAN
Designed for SAS users to learn from experts, connect with peers, and explore what's new.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.