Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
564 views
in Technique[技术] by (71.8m points)

sas - Randoming symbols from a-Z

I need to generate a string from random characters in range of a-Z. How can i do it?

Atm, i can only suggest randoming numbers in range of 1-52 and then reinitialize numbers with charecters. But that sounds awful.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

CALL RANPERM seems well suited for this task.

25         data shuffle(keep=a: drop=addr);
26            array a[52] $1;
27            addr = addrlong(a1);
28            call pokelong(cat(collate(65,90),collate(97,122)),addr,52);
29            put @20 a[*];
30            seed=1234567890123;
31            do n=1 to 10;
32               call ranperm(seed,of a[*]);
33               put seed= @20 a[*];
34               output;
35               end;
36            stop;
37            run;

                   A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z
seed=295748501     i U I K e d H R b E D k u N c v B M T Z G V n A s W h r q Q j F J o x X O p g t Y w z P C m S l L f a y
seed=766887342     z F v U N G M q u H P Q Z d y b X l a D f p Y w m o r V A B n J I j e g c S x R T K O L i s k C h E W t
seed=618158873     L v x k T r c m S e F w n Z K G P t q E W C h M z X p d N o H Y V i s Q u y f B J O g l U R D b I a j A
seed=632090736     J l H Y T R A p N x C v U b w K V W d X t L y E G o Q B M z I S n q k f s O F P D j a r m i c g Z h e u
seed=1911942895    t G j Z e K q H x m L F A g T h v W a y V C B M k I r J S R P s Y Q p w O D E l X U o z u N d f n i b c
seed=479260872     Y Q i d P R z S G B a D K Z X j M E b h T m c e C I n x y w o A k r U f H u l N W s v J p L q O t g V F
seed=1143672881    L X i f a u m K T g x p E M o B q Z s c t A Q I P G D z U d H S y V J F j h r e l v C b k Y W R O w N n
seed=869134054     F D U g G w A Y J o e p r b H z q d l I L M v R W h y m t S n V x T P C K B k O Q i j s c N f Z a X E u
seed=481233318     n h P j V M y S W s m F a G l q f d o O A u T I E p k z b e C X t v Q H i w c U g Z K B R N L x r D J Y
seed=1445828380    d P t o N h c R r M l n E y g F x z S a W L G p w T Q k B H e v I K i b f q X C m Y D J Z V j A U u O s

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...