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

Stata — create rows of repetitive data


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:

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.


Use JSON file to insert data in database

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:...

Unknown Data Structure?

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,...

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

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...

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...

parsing JSON files in python to get specific values

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" : "", "Hosts" :...

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

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...

Powershell Data input [closed]

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...

R Data Wrangling for Emails

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...

Pass data through unwind 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)...

Double integration using experimental data

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...

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

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...

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

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...

write table in R

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...

Awk Script to process data from a trace file

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...

Return data from async function [duplicate]

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......

Read data only when it is present

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...

R: Matching by row and column

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...

Autofilter Column data one by one using buttons

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...

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

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...

Ambari Monitoring raw data

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...

Global name 'bluetooth' is not defined

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...

Python pandas trouble with storing result in variable

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...

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

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...

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

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: And it works fine to...

Spring Data JPA user posts

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...

jQuery set alternating color rows

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...

Can I use scikit-learn with Django framework?

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...

Send events to two separate google analytics accounts?

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

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

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...

SVG data image not working on Firefox

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="" xmlns: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...

AngularJS Spring sort field names

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 */...

Building totals based on condition in another row

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...

Google Linechart - No Pointsize, Tooltips?

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...

How to set GridView's Row

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); }...

JavaScript: Add table values to input field on button click

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>...

Insert data in collection at Meteor's 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:...

Swift xcode advise where to store data

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...

Select n rows after specific number

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...

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

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...

jquery use data tag selector after updating data tag on element

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...

Data Analysis and Scatter Plot different file and different column

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=[]...

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

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...

Polymer 1.0 data binding not working

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() {; console.log(this.navigator.currentStep); // 2 } }); Output...

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

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...

mean day with hourly data from a week matlab

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...

Grouping Data first by frequency, then by category in python

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...

Elasticsearch data model

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:...

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

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...

Most efficient way to implement table with multiple column?

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...

Replicating tables within the database

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...