BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

Hi, I'm trying to use proc similarity (hope someone is familiar with it) and it needs sequential column variables, eg. Var1 Var2, Var3, ... Var1000, but when I sort it, it sorts as Var1, Var10, Var100, Var101, Var2, ... Var999... How can I keep the normal numbering system 1,2,3,...1000 .. If anyone knows proc similarity, I have 2 groupings that would duplicate the Date which is the ID variable.  I'm trying to use a by statement in proc similarity but I'm getting an error that the ID (date) is duplicated from all these groups.  Any suggestions, thanks.

4 REPLIES 4
art297
Opal | Level 21

I provided one possible solution in a different thread where you asked this question.  I'm not familiar with proc similarity but, in order to make the variable values so that they sort correctly, use put(_n_,z4.) rather than just _n_.

That way you don't have to do anything extra in order to get it to sort as desired.

podarum
Quartz | Level 8

Thanks art..

Tom
Super User Tom
Super User

You can use variable lists in RENAME statement (or data set option) to add in the leading zeros.

data new ;

  set old;

  rename v1-v1000=v0001-v1000;

run;

proc XXXX data=old(rename=(v1-v1000=v0001-v1000));

....

Linlin
Lapis Lazuli | Level 10

Hi Tom,

I think that v1-v1000 are values of one variable of the OP's dateset, not v1-v1000 variables. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 4 replies
  • 1271 views
  • 3 likes
  • 4 in conversation