BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JoeMadden
Fluorite | Level 6

Afternoon All,

Anyone able to create a Unique Index with Proc SQL and the PW= option for a protected dataset?

Works fine when creating a simple index (example);

Proc Sql;

     Create Index MY_COL on MY_DATASET (PW=MYPASS);

Quit;

However, I've tried different permutation of syntax and failed miserably, the only way I have been able to get it to successfully work is to remove the dataset protection

then apply the UI and then re-apply the protection.

No Protection (OK)

Proc Sql;

     Create Unique Index MY_INDEX on MY_DATASET (COL1,COL2);

Quit;

Protection (???) - All incorrect syntax

Proc Sql;

     Create Unique Index MY_INDEX on MY_DATASET (PW=MYPASS COL1,COL2);

     Create Unique Index MY_INDEX on MY_DATASET ((PW=MYPASS) COL1,COL2);

     Create Unique Index MY_INDEX on MY_DATASET (PW=(MYPASS) COL1,COL2);

     Create Unique Index MY_INDEX on MY_DATASET (COL1,COL2) (PW=MYPASS);

Quit;

Thank you in advance! Smiley Happy

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

How about this one :

data class;
 set sashelp.class;
 run;
 
proc datasets lib=work nodetails nolist;
modify class(pw=abc);
index create name/unique;
quit;

Xia Keshan

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I believe, and only guessing here, that the (pw=) option is only available on the from part of SQL.  I would assign the pw in a post step:

proc sql;

     create unique index MY_INDEX

     on     MY_DATASET (COL1,COL2);

quit;

data my_dataset (pw=xyz);

     set my_dataset;

run;

JoeMadden
Fluorite | Level 6

Thanks RW9, I suspected this maybe the case!

I'd be interested to know if the unique index is lost in the second step when dataset is re-created.

Joe.

Ksharp
Super User

How about this one :

data class;
 set sashelp.class;
 run;
 
proc datasets lib=work nodetails nolist;
modify class(pw=abc);
index create name/unique;
quit;

Xia Keshan

JoeMadden
Fluorite | Level 6

Thank you Xia!

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 926 views
  • 1 like
  • 3 in conversation