Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Invalid name r(198); with replace and round

    Dear Statalist,

    I have numbers that I would like to turn into integers.

    Here is the dataex example for two of the four categories:

    Code:
    dataex endw_bondsgov* endw_equit*
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str16 endw_bondsgov1 str15(endw_bondsgov2 endw_bondsgov3 endw_bondsgov4 endw_equit1 endw_equit2 endw_equit3 endw_equit4)
    "72.5367294144"   "26.716937778019" "6.1249883251715" "7.0152059347681" "12.515152172732" "32.473667978589" "86.461801858638" "77.505463790948"
    "0"               "0"               "0"               "0"               "65.044106947981" "88.421229613854" "75.336485994907" "100"            
    "0"               "0"               "19.350244428192" "19.594901919038" "95.61477850068"  "100"             "31.629392971246" "49.669515062952"
    "11.864186595807" "49.188611408026" "27.658265054929" "28.914301167699" "82.053734868615" "19.949470411039" "72.341734945071" "0"              
    "53.442847998615" "0"               "0"               "87.535714650293" "37.637537377805" "100"             "100"             "0"              
    "28.204836393541" "0"               "0"               "12.984242078599" "19.599851345844" "84.730193627096" "92.252341961286" "14.621936764313"
    "34.78336644707"  "19.173384960653" "39.323758751614" "0"               "54.672522569626" "69.817281667485" "49.839290742953" "89.56170327675"
    "48.246457343921" "8.3044147630342" "23.503813579149" "42.660202360877" "32.449191486089" "73.096159447426" "76.496186420851" "46.189924114671"
    "0"               "13.190793090885" "79.36063885923"  "0"               "100"             "59.418159728845" "0"               "100"            
    "44.945557971514" "0"               "0"               "27.072384552576" "0"               "100"             "98.178272193214" "43.749404279495"
    "0"               "16.54853799542"  "0"               "25.284516923818" "100"             "58.272176790316" "100"             "13.145818176606"
    "0"               "27.092353403151" "0"               "28.083822999828" "84.730193627096" "21.953316568496" "93.665097825347" "29.202442899904"
    "0"               "0"               "0"               "0"               "100"             "43.080869964773" "88.175131896629" "81.720657774014"
    "12.289996124355" "0"               "59.791630426101" "0"               "86.744264097653" "93.389521021039" "35.709825031538" "100"            
    "0"               "0"               "0"               "12.138486269918" "100"             "64.485747622105" "100"             "68.388979675014"
    "0"               "49.446225876891" "38.240713337852" "0"               "82.013687835888" "10.776464107961" "30.608036507012" "89.222077357671"
    "11.440089279614" "65.822057216087" "32.501619353008" "9.5497155138501" "65.158175234017" "23.647808224341" "56.305305589311" "79.483415368968"
    "47.518242093678" "11.706915511019" "0"               "0"               "24.595733868242" "46.551635312745" "0"               "100"            
    "18.60868490546"  "0"               "7.3081749197645" "23.711886154643" "26.210619377889" "90.939680827616" "68.709779960983" "25.545856925266"
    "58.346453259959" "0"               "16.589431116454" "49.682730570303" "27.251500515916" "100"             "71.848188425597" "36.805209280497"
    "27.252348711967" "19.533708956674" "19.37399022833"  "0"               "63.307241596122" "21.286186127841" "80.62600977167"  "100"            
    "0"               "0"               "15.045522223817" "0"               "58.266487278968" "82.028308915449" "84.954477776183" "46.688684142069"
    "57.26678215265"  "11.725169929753" "68.291496554938" "23.328860697645" "19.897658713309" "88.274830070247" "12.624320687335" "76.671139302355"
    "4.6898469059325" "22.924092257456" "0"               "28.229656079684" "71.548386494883" "53.252696208062" "100"             "40.169141138884"
    "12.024979076178" "4.1449610182618" "30.676468569204" "17.323496785877" "67.74947315064"  "85.647371460118" "29.744196844463" "20.665659642592"
    "48.628313179431" "0"               "51.32301699609"  "23.587056141753" "25.296201294736" "76.088524819064" "22.227801362325" "52.879937959721"
    "4.9099391834874" "4.7988698331268" "4.8171521348358" "8.8182977726488" "69.696499413174" "79.883126087858" "5.5951253454974" "76.21411031766"
    "33.821919491194" "0"               "14.507057638734" "0"               "29.30758016554"  "77.728391142228" "61.435529825778" "84.106943955665"
    "17.048932948431" "0"               "32.280229202826" "0"               "33.240031832598" "45.400781810603" "37.972953758079" "29.160164956193"
    "21.242702180727" "0"               "0"               "0"               "23.922031498602" "27.078718036395" "58.266487278968" "52.723988047506"
    "9.472190692395"  "36.969803728873" "0"               "30.820362833125" "80.870223231177" "53.675563920231" "100"             "16.718139610987"
    "27.86981357241"  "7.0996573987875" "27.084073410319" "0"               "52.308360809218" "77.87423721091"  "58.259088104111" "100"            
    "0"               "65.03578551591"  "78.485441141149" "3.4901758296849" "96.120231294665" "30.056180268545" "11.048095359919" "82.034576318855"
    "8.1485836538383" "29.442500266584" "0"               "47.087113244438" "81.970881000792" "49.754258072647" "100"             "46.509817730293"
    "80.202815345309" "18.600815418829" "0"               "0"               "6.1890246909927" "62.551890289103" "100"             "100"            
    "0"               "0"               "17.379983329703" "12.130346559327" "58.071891953499" "75.28611622518"  "37.6505282945"   "54.26479778597"
    "24.283418483606" "43.155335373911" "0"               "0"               "14.772972584011" "0"               "76.088524819064" "100"            
    "0"               "0"               "9.16965163805"   "41.179725769097" "100"             "100"             "56.607689045681" "16.753089709168"
    "9.3367508032912" "21.239054831199" "9.1282797508071" "27.783635645772" "81.3952192567"   "64.096440931207" "81.858942294575" "48.406066377128"
    "42.654400930059" "12.528442812629" "35.761622452791" "8.2467821305768" "20.790650784483" "50.759870706536" "38.462447683909" "58.078598411194"
    "55.687851037571" "5.5588317882171" "26.076318521585" "11.532652354295" "10.45195439573"  "88.417042021501" "56.238594060714" "60.237414062549"
    "38.257514254878" "16.77859026016"  "4.7903240555799" "0"               "51.035806725819" "77.511924698912" "89.708479927613" "100"            
    "78.110469075274" "0"               "8.7309511297951" "89.874828616802" "21.889530924726" "100"             "91.269048870205" "10.125171383198"
    "0"               "0"               "0"               "46.13331217031"  "13.26844552981"  "80.851290380014" "100"             "0"              
    "0"               "0"               "9.7799653703235" "0"               "81.760046508248" "42.697002101847" "31.972140619832" "100"            
    "55.383106735244" "48.908338619408" "0"               "0"               "20.789514951837" "51.091661380592" "100"             "100"            
    "14.046144085981" "0"               "16.041090057483" "14.657820725463" "57.731886626985" "82.410987693849" "34.805194805195" "42.227831061753"
    "0"               "5.973336496427"  "31.115532769541" "0"               "100"             "89.942451552274" "48.532365180918" "100"            
    "7.5947459436155" "8.1946810667698" "0"               "0"               "76.051903407926" "76.201840721"    "84.380587899252" "90.808958962646"
    "5.4777835520333" "29.02764815679"  "8.8357293531633" "33.666485762176" "66.427395955134" "30.200069995334" "82.101643238261" "25.663623308823"
    "0"               "72.115829550812" "0"               "26.076318521585" "94.842597231767" "7.5335160579929" "94.273547551944" "56.238594060714"
    "0"               "8.2805360503901" "0"               "0"               "75.685369808297" "55.949730652193" "71.764703572261" "100"            
    "0"               "12.763887100989" "30.291509694697" "0"               "52.726023136087" "58.066275150381" "57.013627241455" "92.942975095946"
    "1.9380750190477" "5.4468758810644" "1.8010709949702" "0"               "58.95201522281"  "44.318896527793" "62.758354049835" "63.09141611792"
    "0"               "0"               "0"               "17.066023148366" "70.720721885819" "95.493367061416" "100"             "60.730163769377"
    "32.630599542636" "20.261878852256" "55.307192988743" "2.7202334013116" "26.26325838191"  "43.658024909626" "14.444041935676" "86.534365534095"
    "0"               "0"               "27.129745787776" "17.732287818691" "100"             "100"             "43.842100948453" "49.922126682859"
    "19.089290159508" "28.911396260899" "0"               "0"               "22.172222966892" "0"               "64.9333847795"   "55.412724169178"
    "0"               "12.383911008437" "22.602890828682" "0"               "100"             "70.244005854761" "47.120993085778" "100"            
    "8.5311791381855" "0"               "21.603527514703" "29.823281787934" "67.401115620256" "86.999432988257" "55.910592433046" "33.379956787803"
    "0"               "6.8421487411947" "26.076318521585" "26.619274105845" "95.493367061416" "85.771078667239" "56.238594060714" "37.493657679126"
    "0"               "0"               "0"               "0"               "100"             "100"             "38.190739585854" "71.299800442541"
    "81.694630155684" "0"               "76.459873041553" "0"               "6.6366130633637" "100"             "11.767654443159" "100"            
    "3.4683991531088" "4.1857188925106" "23.711886154643" "2.6549101071712" "84.865305150803" "65.991255573168" "25.545856925266" "89.734863067652"
    "32.187865330046" "17.629741435612" "7.5360655643064" "7.2250291316323" "50.437151284288" "33.182086885197" "84.917315593818" "84.519142301751"
    "9.3810313807043" "38.492391005314" "15.149488729084" "0"               "57.836296936701" "16.765851468949" "21.870617766976" "55.724309441336"
    "48.929528304206" "12.50516923771"  "8.8399602738268" "41.683573113086" "25.452891871298" "78.622539129563" "82.140956975136" "31.592741727856"
    "6.8172258174965" "31.743850546616" "7.6069991666445" "25.581230215817" "70.887659302087" "11.399681704389" "71.588147848084" "41.457664218577"
    "18.978300323919" "21.753953384246" "31.852906240581" "26.973752774687" "62.888107653357" "47.594346235489" "32.046649407946" "60.381195364502"
    "0"               "24.138432808673" "0"               "42.459095758932" "100"             "70.317464167051" "100"             "52.882920569863"
    "9.4919845868983" "88.734026087801" "0"               "22.349059646992" "79.153015157155" "0"               "100"             "40.268693072356"
    "46.178896852485" "0"               "31.796402951983" "5.9243665065174" "9.6270671560893" "79.791724170551" "11.418554042926" "70.673342302043"
    "5.2927139174368" "0"               "25.246266685651" "0"               "94.707286082563" "100"             "51.14351607586"  "100"            
    "0"               "31.882414102746" "0"               "19.608184925869" "86.743440849721" "46.02716994607"  "89.075268817204" "69.584459099581"
    "29.700181885744" "24.308812035952" "0"               "0"               "60.227650544679" "65.755666275889" "91.172430687396" "90.700369777582"
    "36.843611257257" "0"               "28.003199196481" "0"               "11.58216339453"  "100"             "62.780510941438" "100"            
    "9.7541257880516" "17.758254575905" "7.0781785496091" "0"               "51.715359302245" "18.510609935453" "77.638641476921" "92.942975095946"
    "74.841183961196" "0"               "0"               "14.35825864509"  "14.659158346789" "90.47631656557"  "100"             "85.64174135491"
    "0"               "0"               "41.297826752372" "48.576750683975" "100"             "90.700369777582" "26.828895010713" "20.736558200904"
    "4.7469607146434" "44.584338670761" "4.6655733427757" "79.067111178363" "79.019034582751" "13.761789866199" "79.666039247843" "5.0105189169665"
    "0"               "27.377772932905" "0"               "48.587814652173" "100"             "44.552242873494" "77.303437693241" "24.632255897104"
    "0"               "0"               "0"               "0"               "100"             "100"             "100"             "100"            
    "0"               "10.450381600554" "0"               "85.602438021914" "91.61204490882"  "36.208160778279" "90.957572160494" "4.0971198861187"
    "16.300126054733" "0"               "3.8916488358138" "0"               "38.312509171342" "91.529918934986" "80.571988701649" "100"            
    "0"               "0"               "8.6682707759662" "19.254835580745" "100"             "81.760046508248" "43.599343299659" "19.523003480477"
    "0"               "19.074858891275" "57.834890062076" "0"               "90.808958962646" "42.764020600924" "22.391754172226" "89.56170327675"
    "0"               "40.551191790304" "52.636740604726" "0"               "100"             "33.883718538783" "24.150679442845" "100"            
    "18.972317098485" "2.6650282213006" "0"               "24.51866024073"  "62.02328609439"  "77.385800417394" "96.248989412196" "54.692305829357"
    "13.942333179809" "9.3553152781342" "5.6230480065028" "12.893572504814" "48.817236657264" "68.261671684886" "78.258639489147" "58.65624811723"
    "0"               "9.4057721748663" "0"               "0"               "81.789887072857" "29.357009204483" "42.761582608035" "69.629278008917"
    "6.4529983434441" "4.0330071405404" "17.490741047905" "9.7541257880516" "58.712768984981" "83.500370339371" "49.380697776346" "51.715359302245"
    "9.9624896066425" "9.4919845868983" "21.027522033164" "8.3241717252821" "75.004207390748" "79.153015157155" "49.083392579533" "70.015438921447"
    "100"             "37.439792689682" "0"               "0"               "0"               "43.486343620607" "100"             "94.027010851768"
    "0"               "0"               "31.840780365009" "0"               "100"             "87.898847676088" "45.967065240193" "100"            
    "79.974552423487" "0"               "16.308394406573" "1.6347827248234" "8.6160099645745" "68.525204083714" "61.390186819626" "64.434191217097"
    "28.950146852744" "11.5959074861"   "4.3230068356509" "4.6874122338932" "42.063233063943" "45.65584504203"  "85.400121655019" "80.03894474714"
    "67.716696149136" "0"               "28.692176554016" "0"               "10.064537449216" "81.915777931059" "25.517050365553" "74.623791407178"
    "67.772782384794" "8.5993167507769" "100"             "4.171867140302"  "12.528431530422" "58.103660568713" "0"               "81.132548641956"
    "8.4635515786861" "32.313790879071" "7.1212670005788" "0"               "61.723218320036" "21.000560381133" "78.111267135229" "84.908354979437"
    "0"               "0"               "59.353656012537" "9.4522213147448" "88.175131896629" "76.044283189134" "11.088771276229" "68.837964633706"
    end


    Code:
    destring endw_*, replace
    worked

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(endw_bondsgov1 endw_bondsgov2 endw_bondsgov3 endw_bondsgov4 endw_equit1 endw_equit2 endw_equit3 endw_equit4)
      72.5367294144 26.716937778019 6.1249883251715 7.0152059347681 12.515152172732 32.473667978589 86.461801858638 77.505463790948
                  0               0               0               0 65.044106947981 88.421229613854 75.336485994907             100
                  0               0 19.350244428192 19.594901919038  95.61477850068             100 31.629392971246 49.669515062952
    11.864186595807 49.188611408026 27.658265054929 28.914301167699 82.053734868615 19.949470411039 72.341734945071               0
    53.442847998615               0               0 87.535714650293 37.637537377805             100             100               0
    28.204836393541               0               0 12.984242078599 19.599851345844 84.730193627096 92.252341961286 14.621936764313
     34.78336644707 19.173384960653 39.323758751614               0 54.672522569626 69.817281667485 49.839290742953  89.56170327675
    48.246457343921 8.3044147630342 23.503813579149 42.660202360877 32.449191486089 73.096159447426 76.496186420851 46.189924114671
                  0 13.190793090885  79.36063885923               0             100 59.418159728845               0             100
    44.945557971514               0               0 27.072384552576               0             100 98.178272193214 43.749404279495
                  0  16.54853799542               0 25.284516923818             100 58.272176790316             100 13.145818176606
                  0 27.092353403151               0 28.083822999828 84.730193627096 21.953316568496 93.665097825347 29.202442899904
                  0               0               0               0             100 43.080869964773 88.175131896629 81.720657774014
    12.289996124355               0 59.791630426101               0 86.744264097653 93.389521021039 35.709825031538             100
                  0               0               0 12.138486269918             100 64.485747622105             100 68.388979675014
                  0 49.446225876891 38.240713337852               0 82.013687835888 10.776464107961 30.608036507012 89.222077357671
    11.440089279614 65.822057216087 32.501619353008 9.5497155138501 65.158175234017 23.647808224341 56.305305589311 79.483415368968
    47.518242093678 11.706915511019               0               0 24.595733868242 46.551635312745               0             100
     18.60868490546               0 7.3081749197645 23.711886154643 26.210619377889 90.939680827616 68.709779960983 25.545856925266
    58.346453259959               0 16.589431116454 49.682730570303 27.251500515916             100 71.848188425597 36.805209280497
    27.252348711967 19.533708956674  19.37399022833               0 63.307241596122 21.286186127841  80.62600977167             100
                  0               0 15.045522223817               0 58.266487278968 82.028308915449 84.954477776183 46.688684142069
     57.26678215265 11.725169929753 68.291496554938 23.328860697645 19.897658713309 88.274830070247 12.624320687335 76.671139302355
    4.6898469059325 22.924092257456               0 28.229656079684 71.548386494883 53.252696208062             100 40.169141138884
    12.024979076178 4.1449610182618 30.676468569204 17.323496785877  67.74947315064 85.647371460118 29.744196844463 20.665659642592
    48.628313179431               0  51.32301699609 23.587056141753 25.296201294736 76.088524819064 22.227801362325 52.879937959721
    4.9099391834874 4.7988698331268 4.8171521348358 8.8182977726488 69.696499413174 79.883126087858 5.5951253454974  76.21411031766
    33.821919491194               0 14.507057638734               0  29.30758016554 77.728391142228 61.435529825778 84.106943955665
    17.048932948431               0 32.280229202826               0 33.240031832598 45.400781810603 37.972953758079 29.160164956193
    21.242702180727               0               0               0 23.922031498602 27.078718036395 58.266487278968 52.723988047506
     9.472190692395 36.969803728873               0 30.820362833125 80.870223231177 53.675563920231             100 16.718139610987
     27.86981357241 7.0996573987875 27.084073410319               0 52.308360809218  77.87423721091 58.259088104111             100
                  0  65.03578551591 78.485441141149 3.4901758296849 96.120231294665 30.056180268545 11.048095359919 82.034576318855
    8.1485836538383 29.442500266584               0 47.087113244438 81.970881000792 49.754258072647             100 46.509817730293
    80.202815345309 18.600815418829               0               0 6.1890246909927 62.551890289103             100             100
                  0               0 17.379983329703 12.130346559327 58.071891953499  75.28611622518   37.6505282945  54.26479778597
    24.283418483606 43.155335373911               0               0 14.772972584011               0 76.088524819064             100
                  0               0   9.16965163805 41.179725769097             100             100 56.607689045681 16.753089709168
    9.3367508032912 21.239054831199 9.1282797508071 27.783635645772   81.3952192567 64.096440931207 81.858942294575 48.406066377128
    42.654400930059 12.528442812629 35.761622452791 8.2467821305768 20.790650784483 50.759870706536 38.462447683909 58.078598411194
    55.687851037571 5.5588317882171 26.076318521585 11.532652354295  10.45195439573 88.417042021501 56.238594060714 60.237414062549
    38.257514254878  16.77859026016 4.7903240555799               0 51.035806725819 77.511924698912 89.708479927613             100
    78.110469075274               0 8.7309511297951 89.874828616802 21.889530924726             100 91.269048870205 10.125171383198
                  0               0               0  46.13331217031  13.26844552981 80.851290380014             100               0
                  0               0 9.7799653703235               0 81.760046508248 42.697002101847 31.972140619832             100
    55.383106735244 48.908338619408               0               0 20.789514951837 51.091661380592             100             100
    14.046144085981               0 16.041090057483 14.657820725463 57.731886626985 82.410987693849 34.805194805195 42.227831061753
                  0  5.973336496427 31.115532769541               0             100 89.942451552274 48.532365180918             100
    7.5947459436155 8.1946810667698               0               0 76.051903407926    76.201840721 84.380587899252 90.808958962646
    5.4777835520333  29.02764815679 8.8357293531633 33.666485762176 66.427395955134 30.200069995334 82.101643238261 25.663623308823
                  0 72.115829550812               0 26.076318521585 94.842597231767 7.5335160579929 94.273547551944 56.238594060714
                  0 8.2805360503901               0               0 75.685369808297 55.949730652193 71.764703572261             100
                  0 12.763887100989 30.291509694697               0 52.726023136087 58.066275150381 57.013627241455 92.942975095946
    1.9380750190477 5.4468758810644 1.8010709949702               0  58.95201522281 44.318896527793 62.758354049835  63.09141611792
                  0               0               0 17.066023148366 70.720721885819 95.493367061416             100 60.730163769377
    32.630599542636 20.261878852256 55.307192988743 2.7202334013116  26.26325838191 43.658024909626 14.444041935676 86.534365534095
                  0               0 27.129745787776 17.732287818691             100             100 43.842100948453 49.922126682859
    19.089290159508 28.911396260899               0               0 22.172222966892               0   64.9333847795 55.412724169178
                  0 12.383911008437 22.602890828682               0             100 70.244005854761 47.120993085778             100
    8.5311791381855               0 21.603527514703 29.823281787934 67.401115620256 86.999432988257 55.910592433046 33.379956787803
                  0 6.8421487411947 26.076318521585 26.619274105845 95.493367061416 85.771078667239 56.238594060714 37.493657679126
                  0               0               0               0             100             100 38.190739585854 71.299800442541
    81.694630155684               0 76.459873041553               0 6.6366130633637             100 11.767654443159             100
    3.4683991531088 4.1857188925106 23.711886154643 2.6549101071712 84.865305150803 65.991255573168 25.545856925266 89.734863067652
    32.187865330046 17.629741435612 7.5360655643064 7.2250291316323 50.437151284288 33.182086885197 84.917315593818 84.519142301751
    9.3810313807043 38.492391005314 15.149488729084               0 57.836296936701 16.765851468949 21.870617766976 55.724309441336
    48.929528304206  12.50516923771 8.8399602738268 41.683573113086 25.452891871298 78.622539129563 82.140956975136 31.592741727856
    6.8172258174965 31.743850546616 7.6069991666445 25.581230215817 70.887659302087 11.399681704389 71.588147848084 41.457664218577
    18.978300323919 21.753953384246 31.852906240581 26.973752774687 62.888107653357 47.594346235489 32.046649407946 60.381195364502
                  0 24.138432808673               0 42.459095758932             100 70.317464167051             100 52.882920569863
    9.4919845868983 88.734026087801               0 22.349059646992 79.153015157155               0             100 40.268693072356
    46.178896852485               0 31.796402951983 5.9243665065174 9.6270671560893 79.791724170551 11.418554042926 70.673342302043
    5.2927139174368               0 25.246266685651               0 94.707286082563             100  51.14351607586             100
                  0 31.882414102746               0 19.608184925869 86.743440849721  46.02716994607 89.075268817204 69.584459099581
    29.700181885744 24.308812035952               0               0 60.227650544679 65.755666275889 91.172430687396 90.700369777582
    36.843611257257               0 28.003199196481               0  11.58216339453             100 62.780510941438             100
    9.7541257880516 17.758254575905 7.0781785496091               0 51.715359302245 18.510609935453 77.638641476921 92.942975095946
    74.841183961196               0               0  14.35825864509 14.659158346789  90.47631656557             100  85.64174135491
                  0               0 41.297826752372 48.576750683975             100 90.700369777582 26.828895010713 20.736558200904
    4.7469607146434 44.584338670761 4.6655733427757 79.067111178363 79.019034582751 13.761789866199 79.666039247843 5.0105189169665
                  0 27.377772932905               0 48.587814652173             100 44.552242873494 77.303437693241 24.632255897104
                  0               0               0               0             100             100             100             100
                  0 10.450381600554               0 85.602438021914  91.61204490882 36.208160778279 90.957572160494 4.0971198861187
    16.300126054733               0 3.8916488358138               0 38.312509171342 91.529918934986 80.571988701649             100
                  0               0 8.6682707759662 19.254835580745             100 81.760046508248 43.599343299659 19.523003480477
                  0 19.074858891275 57.834890062076               0 90.808958962646 42.764020600924 22.391754172226  89.56170327675
                  0 40.551191790304 52.636740604726               0             100 33.883718538783 24.150679442845             100
    18.972317098485 2.6650282213006               0  24.51866024073  62.02328609439 77.385800417394 96.248989412196 54.692305829357
    13.942333179809 9.3553152781342 5.6230480065028 12.893572504814 48.817236657264 68.261671684886 78.258639489147  58.65624811723
                  0 9.4057721748663               0               0 81.789887072857 29.357009204483 42.761582608035 69.629278008917
    6.4529983434441 4.0330071405404 17.490741047905 9.7541257880516 58.712768984981 83.500370339371 49.380697776346 51.715359302245
    9.9624896066425 9.4919845868983 21.027522033164 8.3241717252821 75.004207390748 79.153015157155 49.083392579533 70.015438921447
                100 37.439792689682               0               0               0 43.486343620607             100 94.027010851768
                  0               0 31.840780365009               0             100 87.898847676088 45.967065240193             100
    79.974552423487               0 16.308394406573 1.6347827248234 8.6160099645745 68.525204083714 61.390186819626 64.434191217097
    28.950146852744   11.5959074861 4.3230068356509 4.6874122338932 42.063233063943  45.65584504203 85.400121655019  80.03894474714
    67.716696149136               0 28.692176554016               0 10.064537449216 81.915777931059 25.517050365553 74.623791407178
    67.772782384794 8.5993167507769             100  4.171867140302 12.528431530422 58.103660568713               0 81.132548641956
    8.4635515786861 32.313790879071 7.1212670005788               0 61.723218320036 21.000560381133 78.111267135229 84.908354979437
                  0               0 59.353656012537 9.4522213147448 88.175131896629 76.044283189134 11.088771276229 68.837964633706
    end

    However, then I use
    Code:
    replace endw_* = round(endw_*, 1.0)
    and it no longer works, as I get endw_* invalid name - r(198);

    But if I browse
    Code:
    br endw_*
    , I get all endw_* listed with the respective numbers.

    I am using underscores and * because I have 16 columns of data and would rather not type out every single one.

    Please help me with the rounding of my integers

    Thank you very much in advance!

  • #2
    That's not the way replace works. To see that your statement is illegal, see help replace -- which indicates that only a variable name is allowed before the equals sign.

    You need a loop

    Code:
    foreach v of var end_w* { 
        replace `v' = round(`v', 1) 
    }
    Doing it collectively without a loop is possible in Mata.

    Comment


    • #3
      Thank you so much, Nick!

      Comment

      Working...
      X