data,rows,stata , Stata — create rows of repetitive data

Question:

Tag: data,rows,stata

I have to create the following data in Stata several times (say 50,000) -- one below the other. There need to be two variables: (1) a counter going from 1 to 500; and (2) a string variable that is A for the first 25 observations and then B for observations 26 to 500. Then this process needs to be repeated 50,000 times so that there are a total of 50,000*500 rows.

So far the way I have done this is by creating a csv file with the 500 rows and 2 variables and then reading and appending it. It is a really slow and inefficient way of doing this. How can I do this within Stata?

I'm still inclined to consider this question off-topic. It looks like a simple code request. I'll answer with the hope that future questions more clearly state what the programming problem is (including code).

One way is:

``````clear
set more off

// change to 500
set obs 15

gen counter = _n

// change numbers
gen strvar = "A" in 1/5
replace strvar = "B" in 6/15

// change to 50,000
expand 3

bysort counter : gen seq = _n
sort seq counter

// list
list, sep(15)
``````

That's an example, so you need to adjust the numbers. The key command is `expand`.

Related:

Double integration using experimental data

matlab,data,integration,splines
I need to perform a double integration using experimental data, but my integration limits are the same for each integral, in this case, the time. Mathematically I need to calculate: E [ a0+ ∫0T a(t)dt ] = a + limTx → ∞ (1/T) ∫0T ∫0t a dt dT After some...

How do I display my mysql table column headers in my php/html output?

php,html,mysql,table,data
2 Questions... Scenario: I would like to query my database table via a form and then display the results that occur(if there are results) and my current situation is that it does work but it clears the form completely and leaves my to an empty page with just the results...

Use JSON file to insert data in database

javascript,json,mongodb,meteor,data
I'm using my JSON file like this to insert data in my collection : var content = JSON.parse(Assets.getText('test.json')); console.log('inserting...'); Profiles.insert({ user: id, data:content }; But I would like to have a "data's tree" like that : [ user: "rtegert23423131", firstname:"test", surname:"test2", // ... ] Not like that : [ user:...

How to store simple text data in the python program itself? [closed]

python,data
I'm making a program to ease my work. The concept of it is that it has some company names (I'll make a button to add more of them) and stores the info when and what loan they took. So basically I open the program, it displays the company names, I...

Polymer 1.0 data binding not working

data,binding,polymer
I have the following polymer element: The value of navigator.currentStep is not updating after someMethod is called. <dom-module id="m"> <template> Navigator step = <span>{{navigator.currentStep}}</span> </template> </dom-module> Polymer({ is: 'm', ready: function() { this.navigator = new Navigator(1); console.log(this.navigator.currentStep); // 1 }, someMethod: function() { this.navigator.next(); console.log(this.navigator.currentStep); // 2 } }); Output...

Replicating tables within the database

java,database,database-design,data
I have table A, B and C with data that is similar, but with different structure. I need to access the data from my program (Java, in this case) and I'm thinking of having a mini-ETL process that will run daily replicating data from these three tables into a new...

How to show data from database depending on user's choice from a select

php,jquery,database,select,data
I have to make a select and when user choose option from it, it should be displayed data from database based on this select. I can't use submit. It only should be displayed this select and when option is selected, to show data from this select. I'm new to jQuery...

R: Matching by row and column

r,match,rows
I have two data frames, as below: EquityData ValuationDate Currency Opening Closing 02/01/2003 CHF 0 0 02/01/2003 DKK 0 0 03/01/2003 CHF 0 0 02/01/2003 SEK 0 0 03/01/2003 SEK 0 0 04/01/2003 SEK 0 0 05/01/2003 CHF 0 0 03/01/2003 DKK 0 0 which contains information about trades done...

SVG data image not working on Firefox

css,image,firefox,svg,data
I'm setting a SVG as background-image for a pseudo element: content: ''; position: absolute; right: 0; bottom: 0; left: 0; width: 100%; height: 12px; background-image: url('data:image/svg+xml;utf8,<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 620 12" enable-background="new 0 0 620 12" xml:space="preserve"><g><polygon fill="#D11A3C" points="48.8,12 0,12 0,0 54.1,0"/><polygon fill="#952592" points="93.8,12 44,12...

Trying to return one dataset from a function that prints from two functions

python,list,csv,input,data
In this program I am trying get the dataPrinter() function to return just one set of data. Right now the program works well but I would like for it to return just one dataset that includes data from both gen1 and gen2. As shown below, I have already tried creating...

Autofilter Column data one by one using buttons

function,excel-vba,data,filter
I have a some filtered data in a column that I would like to see for one value at a time by a macro. so far I have got up to the code below but it filters out when I manually select a value from the column. Is it possible...

Ambari Monitoring raw data

api,data,monitoring,ambari
For my masters project, I'm looking for a convenient way to grasp the monitoring data Ambari collects. To be precise, I'm interested in the raw data (can be csv, xml, json, you name it) of the charts Ambari shows in the dashboard, i.e., Cluster CPU, Disk Usage, network usage and...

mean day with hourly data from a week matlab

matlab,data,average,mean,days
I have a matrix with 24*7 rows(hourly data from the column week) and 52 columns(weeks in a year). I want to calculate the average day(with 24h) from each week (resulting with a 24-by-52 matrix). Normaly I would reshape the vector from each week so that I could have 24 rows...

Convert String “2008-02-10T12:29:33.000” to a Date with the same format 2008-02-10T12:29:33.000 in Java [duplicate]

java,string,data,transform,simpledateformat
This question already has an answer here: Java string to date conversion 9 answers I have an ArrayList that contains strings like 2008-02-10T12:29:33.000 [2008-02-11T12:29:33.000, 2008-02-10T12:29:33.000]... I want to sort this ArrayList in natural order. For this I have to convert this strings into a Date I quess. The order...

Awk Script to process data from a trace file

table,awk,rows,trace
I have a table (.tr file) with different rows (events). **Event** **Time** **PacketLength** PacketId sent 1 100 1 dropped 2 100 1 sent 3 100 2 sent 4.5 100 3 dropped 5 100 2 sent 6 100 4 sent 7 100 5 sent 8 100 6 sent 10 100 7...

How to set GridView's Row

c#,asp.net,gridview,rows
I have a GridView containing Excel sheet Records. And I want to add them to my DataTable. I want to access my GridView's second row.This is a piece of my code. foreach (GridViewRow row in GridView1.Rows) { string Template = row.Cells[0].Text; string Cust_Name = row.Cells[1].Text; int Invoice_No = int.Parse(row.Cells[2].Text); }...

AngularJS Spring sort field names

angularjs,spring,model-view-controller,data,hateoas
I'm developing an application using AngularJS for the front-end part and Spring for the back-end. I have mainly two entity classes : @Entity public class Project implements Serializable { private static final long serialVersionUID = 1L; /** * idProject */ @Id @GeneratedValue(strategy=AUTO, generator="PROJECT_SEQ") private Integer idProject; /** * name */...

write table in R

r,data
I'm trying to get my data from R. When I type: write.table(c, "~/XXX/XXX.txt", sep="\t"). I get something like this: "x" "1" 3011.5648786606 "2" 15654.1820393584 "3" 12368.7319176159 "4" 3055.2054987339 "5" 4590.9390484852 "6" 15472.0519755823 "7" 22142.4386253643 "8" 43684.1996516822 "9" 20931.0908837875 "10" 15165.4255765957 "11" 21790.7749747969 "12" 42362.7562956186 ............................. How to get rid of...

Can I use scikit-learn with Django framework?

django,data,scikit-learn,analysis
I would like to make a Web app in which some data is analyzed. Due to it, I read that Django is a good option for doing web apps and that scikit-learn was used for machine learning. Therefore, before starting, does anyone know if it is possible to use that...

Extracting a column from one dataset and creating another dataset with columns from a third dataset in R [duplicate]

r,data,merge,data.frame
This question already has an answer here: How to join (merge) data frames (inner, outer, left, right)? 8 answers So I have these two datasets: ID DOB ID2 count 1 4083 2007-10-01 3625 5 2 4408 2008-07-01 3603 2 3 4514 2007-07-01 3077 3 4 4396 2008-05-01 3413 5...

Select n rows after specific number

r,selection,rows
I work with a data.frame like this: Country Date balance_of_payment business_confidence_indicator consumer_confidence_indicator CPI Crisis_IMF 1 Australia 1980-01-01 -0.87 100.215 99.780 25.4 0 2 Australia 1980-04-01 -1.62 100.061 99.746 26.2 0 3 Australia 1980-07-01 -3.70 100.599 100.049 26.6 0 4 Australia 1980-10-01 -3.13 100.597 100.735 27.2 0 5 Australia 1981-01-01 -2.73...

Spring Data JPA user posts

java,spring,jpa,data
I have user login and profile view, I would like the users to have posts. Can someone guide me in the right direction? I have a user entity: @Entity @Table(name = "usr", indexes = { @Index(columnList = "email", unique = true) }) // using usr because in may conflict with...

Grouping Data first by frequency, then by category in python

python,csv,pandas,data,grouping
I have a large csv file, which is a log of caller data. An example of my file: CompanyName High Priority QualityIssue Customer1 Yes User Customer1 Yes User Customer2 No User Customer3 No Equipment Customer1 No Neither Customer3 No User Customer3 Yes User Customer3 Yes Equipment Customer4 No User My...

Insert data in collection at Meteor's startup

javascript,json,meteor,data,startup
I would like to insert data at Meteor's startup. (And after from a JSON file) At startup, I create a new account and I would like to insert data and link it to this account once this one created. This is the code that creates the new account at startup:...

Unknown Data Structure?

java,data-structures,data
I had a question about whether or not Java has its own data structure for what I am looking for. It is something like a combination of an array, linked list and a tree. If it is not in Java, but exists already as a concept in computer science/other languages,...

Method for Storing and organizing data submitted by user to a website (form, pdf)?

php,sql,database,data,website
I have completed a website for a startup consultancy office and am confused on database part. User is supposed to upload basic information using form and resume in pdf format. How should I organize data so that it get stored, say, in Excel sheet or anything like that. Office people...

Pass data through unwind segue

ios,swift,data,segue
I have been looking all over for an answer for this...I do not know how to pass data through an unwind segue. I know I am supposed to use prepareForSegue but I am not sure what I am supposed to put in. I am trying to pass a variable (myLabel)...

Elasticsearch data model

data,elasticsearch,model,nested,parent-child
I'm currently parsing text from internal résumés in my company. The goal is to index everything in elasticsearch to perform search on them. for the moment I have the following JSON document with no mapping defined : Each coworker has a list of project with the client name { name:...

R Data Wrangling for Emails

r,data,data-cleansing
Need Help! this is a work related project. I need to clean 16,000 emails... Expected to do by hand :( I need to find a away to pull the domain name from the email and place it into a new column, and parse the name into a new column as...

Return data from async function [duplicate]

javascript,node.js,asynchronous,data,return
This question already has an answer here: How to return the response from an asynchronous call? 7 answers Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference 3 answers I've been reading a lot about callbacks, but still don't get it......

jQuery set alternating color rows

jquery,css,rows,alternating
I'm looking for a specific answer to my question. And this is, I have a row containing a quantity of divs (is dynamically set). What I want is alternately the background of divs (3 divs) are set to another color like this: Can this be done by the CSS odd...

Global name 'bluetooth' is not defined

python,data,bluetooth,connect
I am working with the bitalino board and I wanted to print the data with python but when I run the proper code, it shows me the message Global name 'bluetooth' is not defined According to my pc the board is connected via bluetooth. I don't know what the problem...

parsing JSON files in python to get specific values

python,json,parsing,data
I'm trying to simply grab information from a json file using python. I've seen many threads that briefly cover this, however there are some questions that I have that I have not seen answered on here. Let's say I have the following json file: { "href" : "http://www.google.com", "Hosts" :...

mysqli::query() expects parameter 1 to be string, object given

php,mysql,mysqli,output,rows
I had saved the required steps for a parameterized string match query that outputs the subsequent rows. I had lost my files when transferring to a faulty drive. So... I'm trying to mash things together and this isn't working. \$stmt = \$link->prepare("SELECT id,entry,date from table WHERE string=? ORDER by Id...

Most efficient way to implement table with multiple column?

java,data,structure
I am attempting to create a table with multiple column such as The initial implementation I thought was is that use Hashtable with key being "String" and value being "List" of String. But is this the most efficient way? I would be accessing data entry a lot and I am...

Move information-resource stored in the database tables with two step using 'reservation'

mysql,sql,database,data
I need to architect a database and service, I have resource that I need to deliver to the users. And the delivery takes some time or requires user to do some more job. These are the tables I store information into. Table - Description _______________________ R - to store resources...

How to get back my datas from a button to an other php page

php,data
I have a button on a php page with some datas on this same page. My button redirect to an other php page and I want to get back this datas. I tried to do if(isset(\$_POST['button'])){ echo(\$data); } The isset is true (I do a test with a string) but...

How to pair rows by status (someone entered and then exited) in mysql

mysql,rows,procedure,pair
I have a table user_status, where I insert rows: who, status (Entered/Exited), what time. Table looks like this: id user_id status status_date 94 5 Entered 2015-03-30 10:43:44 95 5 Exited 2015-03-30 10:47:38 96 5 Entered 2015-03-30 10:49:12 97 3 Entered 2015-03-30 10:51:14 98 3 Exited 2015-03-30 11:04:12 99 5 Exited...

Swift xcode advise where to store data

ios,xcode,data,store
I have created an app using ionic and cordova and now i want to remake it on iOS. I am working with ios for the first time, and i cannot figure out how to store data. For example: i have a form where user has to input some data, but...

JavaScript: Add table values to input field on button click

javascript,input,data,datatable
I have a DataTable that stores names only. I want to have a button that will add all the names in the DataTable to an text input field. <div id="myTabDiv"> <table name="mytab" id="mytab1"> <thead> <tr> <th>name</th> </tr> </thead> <tbody> <tr> <td>chris</td> </tr> <tr> <td>mike</td> </tr> </tbody> </table> <button id="add" >ADD</button>...

jquery use data tag selector after updating data tag on element

javascript,jquery,data,tags
I want to be able to get a set of elements that match a selector in jQuery. I have HTML with data tag attributes that get altered dynamically by jQuery using the .data(key, value) method. However, after dynamically updating an element's data tag it seems I can no longer use...

Read data only when it is present

matlab,data,serial-port,fscanf
I try to read data from the COM3 port. I'm using : in = fscanf(s); if(in == 'A') fclose(s); break; end The problem is, when no data is send to the com3 port, the fscanf line will wait for a certain time and than give a timeout. Is there a...

Google Linechart - No Pointsize, Tooltips?

data,tooltip,visualization,linechart
I'm using a Linechart from Google, in which I have drawn a graph from JSON data. There are two problems I'm running into I can't seem to fix. Even though I have 'pointSize: 6' in my options, I still can't seem to draw any kind of point, anywhere on the...

Send events to two separate google analytics accounts?

Is it possible to send a tracking event to two separate google analytics accounts?

using nested set model to store Hierarchical data in sqlite how can I move a category into another category

php,database,sqlite,data,hierarchical
I'm trying to store hierarchical data using SQLite. After searching a lot, I chose to use the nested set model instead of an adjacency list, because almost 90% of the operations will be reads and only 10% will be updates/deletes/creates. I followed this example: http://www.phpro.org/tutorials/Managing-Hierarchical-Data-with-PHP-and-MySQL.html And it works fine to...

Data Analysis and Scatter Plot different file and different column

python,data,matplotlib,analysis
i have a lot of files and i want to open, read data1.txt and data2.txt file and then data1.txt file 22. column "x_coordinate" and data2.txt file 23. column "y_coordinate" scatter plot. how can i ? with open('data1.txt') as f: with open('data2.txt') as f2: data1 = f.readlines() data2 = f2.readlines() f1.xArr=[]...

How to get number of rows affected by last several sql statement inside procedure in teradata?

So let I have 3 merge statement inside the procedure: CREATE PROCEDURE SP_Employee(OUT num_rows BIGINT) BEGIN MERGE INTO t1 USING t2 ...; MERGE INTO a1 USING b2 ...; MERGE INTO c1 USING d2 ...; END; How can I get number of rows affected inside procedure? I know about ACTIVE_COUNT, but...

Powershell Data input [closed]

powershell,input,data
I'm looking to make a super simple request for input script that uses said input to be executed in the script below. I can edit the script before I run it each time, but it would be way cooler and more practical if you could just enter the PCname and...

Python pandas trouble with storing result in variable

python,variables,csv,pandas,data
I'm using pandas to handle some csv file, but i'm having trouble storing the results in a variable and printing it out as it is. This is the code that I have. df = pd.read_csv(MY_FILE.csv, index_col=False, header=0) df2 = df[(df['Name'])] # Trying to get the result of Name to the...

Building totals based on condition in another row

tsql,data,pivot
Really struggling to understand the best way of doing this... I have a table of data **StudentID AssessmentCode ResultGroup Result** 46933 12ENG IBLevel HL 46933 12ENG Mark 6 46933 12ECO IBLevel HL 46933 12ECO Mark 5 46933 12GEO IBLevel SL 46933 12GEO Mark 6 46933 12LAN IBLevel HL 46933 12LAN...