Hi All,
I have a DATA SET called FR that has variables like: stu_id, name, age, gender. I want to create a simple index on stu_id using DATA step (Yes, we can do the same by PROC SQL or PROC DATASETS but here I want to create using DATA step).
I have written the below program but unable to create index:
DATA FR1 (INDEX=(stu_id=(stu_id)));
SET FR;
RUN;
Can anybody help me on this?
And also, Is there any way to DELETE the created index by DATA step (I don't want to DELETE using PROC SQL or PROC DATASETS) ?
Thank You,
Yadaw
I could build an index, but don't know how to delete it yet.
data class(index=(name));
set sashelp.class;
run;
proc contents data=class;
run;
Composite index.
data class(index=(comp=(name age)));
set sashelp.class;
run;
proc contents data=class;
run;
Hi All,
I have a DATA SET called FR that has variables like: stu_id, name, age, gender. I want to create a simple index on stu_id using DATA step (Yes, we can do the same by PROC SQL or PROC DATASETS but here I want to create using DATA step).
I have written the below program but unable to create index:
DATA FR1 (INDEX=(stu_id=(stu_id)));
SET FR;
RUN;
Can anybody help me on this?
And also, Is there any way to DELETE the created index by DATA step (I don't want to DELETE using PROC SQL or PROC DATASETS) ?
Thank You,
Yadaw
The tool for creating an index on an existing datset is PROC DATASETS.
I could build an index, but don't know how to delete it yet.
data class(index=(name));
set sashelp.class;
run;
proc contents data=class;
run;
Composite index.
data class(index=(comp=(name age)));
set sashelp.class;
run;
proc contents data=class;
run;
A data set index can be created in different ways
Index management is done with either DATASETS or SQL. Read the documentation for more information about uniqueness and non-null indices and other data index topics such as integrity constraints and foreign keys.
Examples:
data cars(index=(Make Model type_drive=(Type DriveTrain))); set sashelp.cars; run; proc datasets nolist lib=work; modify cars; index delete Make Model; index create Origin; run; proc sql; create index Make on work.cars; drop index type_drive from work.cars; create index type_cyl on work.cars(Type, Cylinders) ;
NOTE: SAS data sets do not have RDBMS features such as triggers or sequence numbers.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: