BookmarkSubscribeRSS Feed
omkar
Calcite | Level 5

1. I have a simple index defined on var1 in sas data set : one

2. when appending the data to the sas dataset in step1 with the new data set for ex: two the index that is already defined for the dataset one is lost.

 

please see the below code.

 

data class(index=(name/unique));    /* index created on name in the work.class*/
set sashelp.class;
run;

proc contents data=class;
quit;

data class1;  /* index is not there  in the work.class1*/
set class (where= (name = 'Alfred'));
run;

proc contents data=class1;
run;

data class;
set class class1 ;
run;

proc contents data=class; /* index is lost in work.class*/
quit;

 

kindly let me if I am doing some thing wrong.

1 REPLY 1
Reeza
Super User

Yes, since you’re creating a new data set. It happens to have the same name but that’s coincidental - and bad practice IMO. 

 

Try PROC APPEND or DATASETS

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 552 views
  • 0 likes
  • 2 in conversation