hi,all
I have a category variable "class" ,I want to create a new variable "NO" which number ariable "class" ,the result as follows:
Thanks a lot!
This would only appear in the log if you did not have your By Statement, which initializes the first. and last. variables.
data have;
input Class Grades;
datalines;
1 367
1 363
1 302
2 349
2 332
2 311
2 311
3 357
3 343
;
data want;
set have;
by class;
if first.Class then No=0;
No+1;
run;
Actually there are some missing with the variable "class" ,so I tried like follows,but the log
notes that variable first.class uninitialized.Any solution? thanks
data want;
set have;
by class;
if Class^=. and first.Class then No=0;
No+1;
run;
This would only appear in the log if you did not have your By Statement, which initializes the first. and last. variables.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.