Tag Archive for data

ASP.NET Query from codebehind (Old School)

SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Product", ConfigurationManager.ConnectionStrings["ConnectionStringValue"].ConnectionString);
DataTable table = new DataTable();
adapter.Fill(table);
Repeater1.DataSource = table;
Repeater1.DataBind();

//Access data in .aspx with <%#Eval("fieldName")%>

source

Read arithmetic binary data using fstreams #2

unsigned short fread_unsigned_short(ifstream &input_file) { //note that the ifstream is passed by reference
    unsigned short num;
    //the cast reinterpretation is very importnant
    input_file.read(reinterpret_cast < char * > (&num),sizeof(unsigned short));
    return num;
}

ifstream input_data;
input_data.open("input.dat",ios::in | ios::binary); //note the modifiers that denote both input file and binary mode
unsigned short num=fread_unsigned_short(input_data);

/*
The above function can be generalized to any numeric datatype like integers, floats e.t.c.
just replace the type 'unsigned short' with the wanted type
*/

source

Self teach SAS Tutorials

Starting SAS under Windows
Tutorial 1: Data Steps Part 1
Tutorial 2: Data Steps Part 2
Tutorial 3: Data Transformation and Selection
Tutorial 4: Displaying the Data
Tutorial 5: Some Basic Statistical Procedures
SAS Analyst tutorial--interactive SAS
SAS Multilevel Interactive 

<a href="http://studysas.blogspot.com/2009/06/subscribe.html

" >http://studysas.blogspot.com/2009/06/subscribe.html
source

Standardising Clinical Data exchange

<a href="http://www.phaseforward.com/news/media/2006/2006_02_GCPj.pdf

" >http://www.phaseforward.com/news/media/2006/2006_02_GCPj.pdf
source

Merging data sets using macro code/ Macro for merging datasets

here is the example, I have 7 datasets i need to merge and each of them having the common variable(usubjid) to merge, and all the datasets having the same prefix dsn(dsn1 to dsn7).

%macro allmerge (n);
data combine;
merge %do i = 1 % to &n;
dsn&i;
%end;
by usubjid;
run;
%mend;
%allmerge (7)

Sarath

<a href="http://www.studysas.blogspot.com

" >www.studysas.blogspot.com
source

Finding the number of observations in the Dataset

First up is the most basic and least efficient method: read the whole data set and increment a counter a pick up its last value. The END option allows you to find the last value of count without recourse to FIRST.x/LAST.x logic.

data _null_;
set test end=eof;
count+1;
if eof then call symput("nobs",count);
run;

read more about 5 more diff ways to find number of observation in a dataset....
: <a href="http://studysas.blogspot.com/2008/08/finding-number-of-observations-in-sas.html

" >http://studysas.blogspot.com/2008/08/finding-number-of-observations-in-sas.html
source

TSQL Function and Check Constraint to Ensure that a Parent Value is Present in the Table

ALTER TABLE [dbo].[Message]  WITH CHECK ADD  CONSTRAINT [CK_Message] CHECK  (([InReplyToId] IS NULL OR [dbo].[CheckInReplyToMessageId]([InReplyToId])>=(0)))
GO
ALTER TABLE [dbo].[Message] CHECK CONSTRAINT [CK_Message]



CREATE FUNCTION [dbo].[CheckInReplyToMessageId]
(
@MessageId BigInt
)
RETURNS bit
AS
BEGIN
DECLARE @RetVal bit

SET @RetVal = (SELECT MessageId
FROM Message
WHERE MessageId = @MessageId)

RETURN isnull(@RetVal, 0)

END

source

Dump only data from MySQL database using mysqldump

mysqldump --no-create-info dbname > `date "+%Y%m%d%H%M%S"`_dbname.sql

source

HTML Meta Data

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="..." />
<meta name="keywords" content="..." />
<meta name="author" content="..." />
<meta name="copyright" content="Copyright 20## ..." />
<meta name="company" content="..." />
<meta name="robots" content="index, follow">
<meta name="revisit-after" content="30 days">
<meta name="author" content="...">
<meta name="contact_addr"="...@domain.com">
<meta name="distribution" content="Global">
<meta name="resource-type" content="document">

source

to_struct method for Ruby hashes

class Hash
def to_struct
Struct.new(*keys).new(*values)
end
end


# then use it like this

h = {:foo => 'bar', :baz => 'boz'}

s = h.to_struct("NameOfMyStruct")

source