# generating random letters

12 messages
Open this post in threaded view
|

## generating random letters

 In response to a post on this list I started by trying to simulate data made up of single letters. I am trying to generate random integers into what I recall as the ASCII values for A to Z. 65 to 90. However, I cannot recall how to convert those values into letters. compute below should look like compute x(#p) = somefunction (RND(RV.UNIFORM(64.5,90.5)). * cases and single letter  items. new file. input program.    vector x (10,a1).    loop id = 1 to 25.       loop #p = 1 to 10.          compute x(#p) =RND(RV.UNIFORM(64.5,90.5)).       end loop.       end case.    end loop.    end file. end input program. ```-- Art Kendall Social Research Consultants``` Art Kendall Social Research Consultants
Open this post in threaded view
|

## Re: generating random letters

 Try the PIB string format. Example below. **************************************************. new file. input program.    vector x (10,F1.0).    loop id = 1 to 25.       loop #p = 1 to 10.          compute x(#p) =RND(RV.UNIFORM(64.5,90.5)).               end loop.       end case.    end loop.    end file. end input program. exe. vector let(10,A1). do repeat let = let1 to let10 /x = x1 to x10. compute let = STRING(x,PIB). end repeat. exe. **************************************************. Andy W apwheele@gmail.com http://andrewpwheeler.wordpress.com/
Open this post in threaded view
|

## Re: generating random letters

 In reply to this post by Art Kendall data list list/n. begin data 65 66 67 90 end data. string s(a8). compute s = string(n, pib2). list. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From:        Art Kendall <[hidden email]> To:        [hidden email], Date:        04/11/2013 06:44 AM Subject:        [SPSSX-L] generating random letters Sent by:        "SPSSX(r) Discussion" <[hidden email]> In response to a post on this list I started by trying to simulate data made up of single letters. I am trying to generate random integers into what I recall as the ASCII values for A to Z. 65 to 90. However, I cannot recall how to convert those values into letters. compute below should look like compute x(#p) = somefunction (RND(RV.UNIFORM(64.5,90.5)). * cases and single letter  items. new file. input program.   vector x (10,a1).   loop id = 1 to 25.      loop #p = 1 to 10.         compute x(#p) =RND(RV.UNIFORM(64.5,90.5)).      end loop.      end case.   end loop.   end file. end input program. -- Art Kendall Social Research Consultants Art Kendall Social Research Consultants View this message in context: generating random letters Sent from the SPSSX Discussion mailing list archive at Nabble.com.
Open this post in threaded view
|

## Automatic reply: generating random letters

 Thank you for your emailing me. I am no longer with Schwartz Research & Consulting, Inc. For your full service research needs or for new client inquiries, please contact our Director of Client Services, Jonathan Acosta-Rubio [hidden email] (813) 207-0332 x227 Otherwise, I can now be reached at: [hidden email]
Open this post in threaded view
|

## Re: generating random letters

 Administrator In reply to this post by Art Kendall I came up with the following but alas it doesn't work as expected ;-( BUG!!!!! in MATRIX? MATRIX. PRINT {65:90} / FORMAT "PIB2". COMPUTE X={65:90} . PRINT X. PRINT X  / FORMAT "PIB2". END MATRIX. Run MATRIX procedure: {65:90}  A X   65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90 X  A ------ END MATRIX ----- Art Kendall wrote In response to a post on this list I             started by trying to simulate data made up               of single letters.               I am trying to generate random integers into what I recall as                     the ASCII values for A to Z. 65 to                       90.                       However, I cannot recall how to                         convert those values into letters.                         compute below                             should look like                             compute x(#p) = somefunction                               (RND(RV.UNIFORM(64.5,90.5)).                                                           *                                   cases and single letter  items.                                 new file.                                 input program.                                    vector x (10,a1).                                    loop id = 1 to 25.                                       loop #p = 1 to 10.                                          compute x(#p)                                   =RND(RV.UNIFORM(64.5,90.5)).                                       end loop.                                       end case.                                    end loop.                                    end file.                                 end input program.                                                               -- Art Kendall Social Research Consultants Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Open this post in threaded view
|

## Re: generating random letters

 Administrator Interesting:  If you transpose the vector it prints . MATRIX. PRINT T({65:90}) / FORMAT "PIB2". END MATRIX. David Marso wrote I came up with the following but alas it doesn't work as expected ;-( BUG!!!!! in MATRIX? MATRIX. PRINT {65:90} / FORMAT "PIB2". COMPUTE X={65:90} . PRINT X. PRINT X  / FORMAT "PIB2". END MATRIX. Run MATRIX procedure: {65:90}  A X   65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90 X  A ------ END MATRIX ----- Art Kendall wrote In response to a post on this list I             started by trying to simulate data made up               of single letters.               I am trying to generate random integers into what I recall as                     the ASCII values for A to Z. 65 to                       90.                       However, I cannot recall how to                         convert those values into letters.                         compute below                             should look like                             compute x(#p) = somefunction                               (RND(RV.UNIFORM(64.5,90.5)).                                                           *                                   cases and single letter  items.                                 new file.                                 input program.                                    vector x (10,a1).                                    loop id = 1 to 25.                                       loop #p = 1 to 10.                                          compute x(#p)                                   =RND(RV.UNIFORM(64.5,90.5)).                                       end loop.                                       end case.                                    end loop.                                    end file.                                 end input program.                                                               -- Art Kendall Social Research Consultants Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Open this post in threaded view
|

## Re: generating random letters

 Administrator Confirmed with my v20 running under Windoze.  In this modified version of David's syntax, only the second PRINT command prints the letters A to Z.  The other two just print A. MATRIX. PRINT {65:90} / FORMAT "PIB2". PRINT T({65:90}) / FORMAT "PIB2". PRINT T(T({65:90})) / FORMAT "PIB2". END MATRIX. David Marso wrote Interesting:  If you transpose the vector it prints . MATRIX. PRINT T({65:90}) / FORMAT "PIB2". END MATRIX. David Marso wrote I came up with the following but alas it doesn't work as expected ;-( BUG!!!!! in MATRIX? MATRIX. PRINT {65:90} / FORMAT "PIB2". COMPUTE X={65:90} . PRINT X. PRINT X  / FORMAT "PIB2". END MATRIX. Run MATRIX procedure: {65:90}  A X   65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90 X  A ------ END MATRIX ----- Art Kendall wrote In response to a post on this list I             started by trying to simulate data made up               of single letters.               I am trying to generate random integers into what I recall as                     the ASCII values for A to Z. 65 to                       90.                       However, I cannot recall how to                         convert those values into letters.                         compute below                             should look like                             compute x(#p) = somefunction                               (RND(RV.UNIFORM(64.5,90.5)).                                                           *                                   cases and single letter  items.                                 new file.                                 input program.                                    vector x (10,a1).                                    loop id = 1 to 25.                                       loop #p = 1 to 10.                                          compute x(#p)                                   =RND(RV.UNIFORM(64.5,90.5)).                                       end loop.                                       end case.                                    end loop.                                    end file.                                 end input program.                                                               -- Art Kendall Social Research Consultants -- Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/"When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
Open this post in threaded view
|

## Re: generating random letters

 In reply to this post by David Marso Jon, Andy, David Thanks, I just could not remember PIB. I posted example syntax using random letters.   in the post about reordering drug regimen. The syntax is effective and readable.  It probably could be more efficient and generalizable. ```Art Kendall Social Research Consultants``` On 4/11/2013 9:44 AM, David Marso [via SPSSX Discussion] wrote: Interesting:  If you transpose the vector it prints . MATRIX. PRINT T({65:90}) / FORMAT "PIB2". END MATRIX. David Marso wrote I came up with the following but alas it doesn't work as expected ;-( BUG!!!!! in MATRIX? MATRIX. PRINT {65:90} / FORMAT "PIB2". COMPUTE X={65:90} . PRINT X. PRINT X  / FORMAT "PIB2". END MATRIX. Run MATRIX procedure: {65:90}  A X   65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90 X  A ------ END MATRIX ----- Art Kendall wrote In response to a post on this list I             started by trying to simulate data made up               of single letters.               I am trying to generate random integers into what I recall as                     the ASCII values for A to Z. 65 to                       90.                       However, I cannot recall how to                         convert those values into letters.                         compute below                             should look like                             compute x(#p) = somefunction                               (RND(RV.UNIFORM(64.5,90.5)).                                                           *                                   cases and single letter  items.                                 new file.                                 input program.                                    vector x (10,a1).                                    loop id = 1 to 25.                                       loop #p = 1 to 10.                                          compute x(#p)                                   =RND(RV.UNIFORM(64.5,90.5)).                                       end loop.                                       end case.                                    end loop.                                    end file.                                 end input program.                                                               -- Art Kendall Social Research Consultants Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" If you reply to this email, your message will be added to the discussion below: http://spssx-discussion.1045642.n5.nabble.com/generating-random-letters-tp5719404p5719409.html To start a new topic under SPSSX Discussion, email [hidden email] To unsubscribe from SPSSX Discussion, click here. NAML Art Kendall Social Research Consultants
Open this post in threaded view
|

## Re: generating random letters

 In reply to this post by Art Kendall At 08:37 AM 4/11/2013, Art Kendall wrote: >In response to a post on this list I started by trying to simulate >data made up of single letters. I am trying to generate random >integers into what I recall as the ASCII values for A to Z. 65 to 90. A less fancy way, but it saves you having to worry about ASCII codes and numeric-to-character, and allows you to select characters at random from any string you please: * cases and single letter  items. new file. input program.     STRING  #ALPH(A26).     COMPUTE #ALPH='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.     NUMERIC id (F3).     vector x (10,a1).     loop id = 1 to 25.        loop #p = 1 to 10.           compute x(#p) = SUBSTR(#ALPH,                                 TRUNC(RV.UNIFORM(1,27)),                                 1).        end loop.        end case.     end loop.     end file. end input program. LIST. List |-----------------------------|---------------------------| |Output Created               |18-APR-2013 13:51:29       | |-----------------------------|---------------|   id x1 x2 x3 x4 x5 x6 x7 x8 x9 x10    1 H  B  C  B  P  W  R  Q  Y  R    2 T  E  R  K  B  N  O  R  O  U    3 O  R  J  M  N  W  X  N  X  S    4 I  Q  M  L  T  N  D  W  X  F    5 K  E  O  F  C  N  K  V  H  U    6 Y  O  Z  V  Z  B  E  X  U  U    7 T  D  H  W  H  U  Y  I  E  F    8 J  Z  N  U  P  N  J  K  L  C    9 R  G  V  M  S  X  K  J  A  P   10 R  H  N  G  S  D  F  L  X  O   11 B  W  A  Y  Z  V  Y  X  D  X   12 F  J  P  H  X  B  N  U  C  B   13 X  R  T  Q  T  I  T  C  B  H   14 A  C  Z  U  T  D  L  J  H  Y   15 V  A  M  N  J  B  W  S  I  V   16 K  I  A  S  O  P  U  U E  U   17 U  J  X  L  P  F  N  P  D  P   18 D  Z  M  U  U V  G  J  A  B   19 A  W  D  R  R Q  W  M  Z  G   20 D  B  W  R  A  V  O  X  G  N   21 J  Z  L  I  B  G  L  V  N  C   22 Z  J  X  X O  G  I  S  Z  Q   23 N  I  B  G  P  S  M  F  C  E   24 W  G  V  T  F  Q  Z  S  C  I   25 U  B  V  Y  C  B  C  R  Z  U Number of cases read:  25    Number of cases listed:  25 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Open this post in threaded view
|

## Re: generating random letters

 Administrator Here is a slightly different approach utilizing the 'no-worry' idea Richard posted. I tend to avoid all the nested LOOP logic of INPUT PROGRAM when using UNIFORM generators in favor of the straight to the jugular 3 liner SAVE(UNIFORM(...) within MATRIX. ** This Macro generates N cases of P variables of Length L from string Charlist **. DEFINE AlphaRandom           (N !CHAREND("/") / P !CHAREND("/") / L !CHAREND("/")/ CharList !CHAREND("/")) .                   !LET !LenAlpha=!LENGTH(!CharList). !IF (!L !EQ 1) !THEN !LET !VLIST= X1 !ELSE !LET !VLIST=!CONCAT('X1 TO X',!L) !IFEND   MATRIX. SAVE (TRUNC(UNIFORM(!N*!P,!L)*!LenAlpha)+1)/ OUTFILE */ VARIABLES !VLIST. END MATRIX. COMPUTE INDEX=MOD(\$CASENUM,!P). IF INDEX=0 INDEX=!P. COMPUTE ID=TRUNC((\$CASENUM-.01)/!P)+1. STRING A (!CONCAT('A',!L)). DO REPEAT @=!VLIST. COMPUTE A=CHAR.CONCAT(RTRIM(A),CHAR.SUBSTR(!QUOTE(!CharList),@,1)). END REPEAT. FORMATS ID INDEX(N3). CASESTOVARS ID=ID/INDEX=INDEX/DROP !VLIST. !ENDDEFINE. SET MPRINT ON. AlphaRandom N=25/P=10/L=2/Charlist abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. RESULT:  ID A.001 A.002 A.003 A.004 A.005 A.006 A.007 A.008 A.009 A.010 001 zt    uE    Xq    Vs    Dp    vP    WO    RA    cC    Gr 002 VX    If    sa    Mi    Cd    oN    gD    Zz    Vl    lX 003 nc    kd    Xc    FB    lh    kr    Zt    Ee    hS    Im 004 XU    oF    DI    bf    hl    Us    ZZ    sP    ZP    Ss 005 nb    va    fq    tH    JY    xD    vM    YE    ao    pz 006 mP    dZ    nH    cL    gL    Zp    kk    fz    Vy    Wl 007 sw    wR    vo    Mj    Ha    KI    xv    fN    IA    ec 008 SP    wR    Gt    ML    sF    uX    Kg    oU    xL    Bx 009 vC    mR    Wo    ik    FZ    ag    Yx    Qz    pg    vo 010 xK    rb    bL    Du    Fr    jU    Yp    BE    YG    WS 011 Cj    iA    xH    iT    Xn    vF    KU    pT    Me    pV 012 YR    st    UU    RP    pE    EF    GJ    qV    VL    Oz 013 YB    Ni    RV    te    oZ    We    II    AV    qX    ly 014 jN    Qv    nW    XK    Mx    aH    je    EV    Zk    iE 015 tz    Gn    ir    mD    nh    hi    DV    dX    kL    Xh 016 Qb    NQ    Sc    mp    Lg    ij    tz    bW    Ao    KX 017 bA    Vp    Ap    Cz    Xs    AK    zj    Ed    YT    gx 018 so    Fx    Ig    OD    WC    ld    tp    Yt    dk    fM 019 Qg    go    jk    Wi    Sr    AS    Rv    GK    kw    Ud 020 zW    NO    cB    hM    YO    DX    kv    FZ    WX    RL 021 eX    xS    hX    PU    dq    al    nz    YR    qx    Ub 022 Dy    fU    km    ba    dD    BA    cc    Bl    AJ    ef 023 TZ    FI    gE    by    IT    Hw    xc    Es    qa    hZ 024 Qw    aM    Eg    oM    ak    uC    mE    iQ    Bc    Cg 025 Pd    fa    bA    sI    Kl    XP    Ep    py    pr    Xb Number of cases read:  25    Number of cases listed:  25 Richard Ristow wrote At 08:37 AM 4/11/2013, Art Kendall wrote: >In response to a post on this list I started by trying to simulate >data made up of single letters. I am trying to generate random >integers into what I recall as the ASCII values for A to Z. 65 to 90. A less fancy way, but it saves you having to worry about ASCII codes and numeric-to-character, and allows you to select characters at random from any string you please: * cases and single letter  items. new file. input program.     STRING  #ALPH(A26).     COMPUTE #ALPH='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.     NUMERIC id (F3).     vector x (10,a1).     loop id = 1 to 25.        loop #p = 1 to 10.           compute x(#p) = SUBSTR(#ALPH,                                 TRUNC(RV.UNIFORM(1,27)),                                 1).        end loop.        end case.     end loop.     end file. end input program. LIST. List |-----------------------------|---------------------------| |Output Created               |18-APR-2013 13:51:29       | |-----------------------------|---------------|   id x1 x2 x3 x4 x5 x6 x7 x8 x9 x10    1 H  B  C  B  P  W  R  Q  Y  R    2 T  E  R  K  B  N  O  R  O  U    3 O  R  J  M  N  W  X  N  X  S    4 I  Q  M  L  T  N  D  W  X  F    5 K  E  O  F  C  N  K  V  H  U    6 Y  O  Z  V  Z  B  E  X  U  U    7 T  D  H  W  H  U  Y  I  E  F    8 J  Z  N  U  P  N  J  K  L  C    9 R  G  V  M  S  X  K  J  A  P   10 R  H  N  G  S  D  F  L  X  O   11 B  W  A  Y  Z  V  Y  X  D  X   12 F  J  P  H  X  B  N  U  C  B   13 X  R  T  Q  T  I  T  C  B  H   14 A  C  Z  U  T  D  L  J  H  Y   15 V  A  M  N  J  B  W  S  I  V   16 K  I  A  S  O  P  U  U E  U   17 U  J  X  L  P  F  N  P  D  P   18 D  Z  M  U  U V  G  J  A  B   19 A  W  D  R  R Q  W  M  Z  G   20 D  B  W  R  A  V  O  X  G  N   21 J  Z  L  I  B  G  L  V  N  C   22 Z  J  X  X O  G  I  S  Z  Q   23 N  I  B  G  P  S  M  F  C  E   24 W  G  V  T  F  Q  Z  S  C  I   25 U  B  V  Y  C  B  C  R  Z  U Number of cases read:  25    Number of cases listed:  25 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
 In reply to this post by Richard Ristow Much neater than what I did.  It also could be easily generalized to have several single letter variables. ```Art Kendall Social Research Consultants``` On 4/18/2013 1:58 PM, Richard Ristow wrote: At 08:37 AM 4/11/2013, Art Kendall wrote: In response to a post on this list I started by trying to simulate data made up of single letters. I am trying to generate random integers into what I recall as the ASCII values for A to Z. 65 to 90. A less fancy way, but it saves you having to worry about ASCII codes and numeric-to-character, and allows you to select characters at random from any string you please: * cases and single letter  items. new file. input program.    STRING  #ALPH(A26).    COMPUTE #ALPH='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.    NUMERIC id (F3).    vector x (10,a1).    loop id = 1 to 25.       loop #p = 1 to 10.          compute x(#p) = SUBSTR(#ALPH,                                TRUNC(RV.UNIFORM(1,27)),                                1).       end loop.       end case.    end loop.    end file. end input program. LIST. List |-----------------------------|---------------------------| |Output Created               |18-APR-2013 13:51:29       | |-----------------------------|---------------|  id x1 x2 x3 x4 x5 x6 x7 x8 x9 x10   1 H  B  C  B  P  W  R  Q  Y  R   2 T  E  R  K  B  N  O  R  O  U   3 O  R  J  M  N  W  X  N  X  S   4 I  Q  M  L  T  N  D  W  X  F   5 K  E  O  F  C  N  K  V  H  U   6 Y  O  Z  V  Z  B  E  X  U  U   7 T  D  H  W  H  U  Y  I  E  F   8 J  Z  N  U  P  N  J  K  L  C   9 R  G  V  M  S  X  K  J  A  P  10 R  H  N  G  S  D  F  L  X  O  11 B  W  A  Y  Z  V  Y  X  D  X  12 F  J  P  H  X  B  N  U  C  B  13 X  R  T  Q  T  I  T  C  B  H  14 A  C  Z  U  T  D  L  J  H  Y  15 V  A  M  N  J  B  W  S  I  V  16 K  I  A  S  O  P  U  U E  U  17 U  J  X  L  P  F  N  P  D  P  18 D  Z  M  U  U V  G  J  A  B  19 A  W  D  R  R Q  W  M  Z  G  20 D  B  W  R  A  V  O  X  G  N  21 J  Z  L  I  B  G  L  V  N  C  22 Z  J  X  X O  G  I  S  Z  Q  23 N  I  B  G  P  S  M  F  C  E  24 W  G  V  T  F  Q  Z  S  C  I  25 U  B  V  Y  C  B  C  R  Z  U Number of cases read:  25    Number of cases listed:  25 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD Art Kendall Social Research Consultants