### SAS Converting string values into numeric values

proc contents data=xxx1 position;
ods output position=kuekawa1;
run;

data kuekawa2;
set kuekawa1;
if type="Char" then do;
x1=compress(variable||"_n=input(");
x2=x1||variable||",7.);";
syntax=compress(x2);
*&var1._n=input(&var1,7.);
end;
if syntax ne "";
keep syntax;
run;

data _null_;set kuekawa2;
blank=' ';
file "C:\temp\proc_contents1.txt";
put
(syntax) (100.0);
run;

data xxx2;
set xxx1;
%include "C:\temp\proc_contents1.txt";
run;

### Using PROC LOGISTIC to Estimate the Rasch Model by Pan and Chen

http://support.sas.com/resources/papers/proceedings11/342-2011.pdf

Can this be right?  If right, it helps reduce the computational demand off the procedure.   Page 4:

"When thousands of persons take a test, the procedure takes a long time to estimate the parameters. It is well known that the Rasch model gives the same parameter estimates for each person who receives the same total score. So, variable ‘person’ is able to be replaced with variable ‘total’ when all examinees answer all items as shown by Nord (2008). After the model is fit, the estimate of the parameter for each person is equal to the estimate of the parameter of the total score corresponding to the person’s total score. The third code example and its output are shown as follows:"

### SAS Read from the Web

filename foo url "http://www.cnn.com";
data jaz;
infile foo length=len /*lrecl=32767*/;
input record \$varying1000. len ;
put record \$varying1000. len ;
if _n_=10 then stop;
run;

### SAS Create a sequence of numbers based on a variable by group

Thanks K,

data test;
input x1 x2;
cards;
1 21
1 21
1 35
2 16
2 22
2 22
;

run;

data test2;
set test;
by x1 x2;
if first.x1 then new=0;
if first.x2 then new+1;
proc print;
run;

/* results */

Obs x1 x2 new

1 1 21 1

2 1 21 1

3 1 35 2

4 2 16 1

5 2 22 2

6 2 22 2

### SAS PROC IMPORT EXPORT for CSV files

PROC IMPORT OUT= WORK.asdf
DATAFILE= "C:\temp.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;

PROC EXPORT DATA= WORK.KAZ1
OUTFILE= "C:\sql.csv"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;

### MySQL Basic codes

DROP TABLE data._01_abc;

CREATE TABLE data._01_abc (

var1(22) NULL,

var2 int NULL,
var3 char(2) NULL);

INTO TABLE data._01_abc
COLUMNS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES;

### To request detailed log report off the macro

Options symbolgen mlogic mprint mfile;

### SAS PROC IMPORT

PROC IMPORT OUT= WORK.list
DATAFILE= ".....xlsx"
DBMS=EXCEL REPLACE;
RANGE="Sheet1\$";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;

### SQL: Create Table and Bulk Insert

CREATE TABLE DFC3
(
xxx VARCHAR(30),
xxx INT ,
xxx VARCHAR(30),
xxx VARCHAR(19),
xxx VARCHAR(6),
xxx INT,
xxx INT ,
xxx VARCHAR(19),
xxx INT ,
x  INT ,
xxx VARCHAR(33),
xx INT ,
x INT ,

)

GO
BULK
INSERT DFC3
FROM 'xxxx.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
SELECT TOP 10 *
FROM DFC3
GO
SELECT *
FROM DFC3
GO