Friday, September 4, 2009

SAS: How to Retian a Char Variable in SAS

data temp;
infile cards;
input hosp $3.;
cards;
abc
opq
xyz
;
run;
data tttt;
retain hosplist;
retain cnt;

length hosplist $200;

set temp;
if _n_ = 1 then hosplist = hosp;
*else hosplist = hosplist hosp;
else hosplist = trim(hosplist) hosp;


if _n_ = 1 then cnt = 1;
else cnt + 1;

put _all_;
run;

Wednesday, August 12, 2009

Excel: Creating Data Lables for XY Scatter Plot

Sub DataLabelsFromRange()
Dim Cht As Chart Dim i, ptcnt As Integer
Set Cht = ActiveSheet.ChartObjects(1).Chart On Error Resume Next Cht.SeriesCollection(1).ApplyDataLabels _ Type:=xlDataLabelsShowValue, _ AutoText:=True, _ LegendKey:=False ptcnt = Cht.SeriesCollection(1).Points.Count For i = 1 To ptcnt Cht.SeriesCollection(1).Points(i).DataLabel.Text = _ ActiveSheet.Cells(i + 1, 1).Value
Next i
End Sub


Note -
Column1 - Labels
Column2 - X Values
Column3 - Y Values
Create Scatter Plot with XY values first and then run the above piece of code.

Wednesday, July 29, 2009

SAS: How to Get ParameterEstimates into a SAS Data set

/* How to Get ParameterEstimates into a Data set */
data test;
input x1 x2 y;
datalines;
12 23 34
23 34 34
34 23 34
;
run;
ods trace on;
proc reg data=test;
model y= x1 x2;
ods output ParameterEstimates=ParmEst;
run;
ods trace off;
/* Name of the Data set you will get it from Log file - Example is ParameterEstimates */
Output Added:
-------------
Name: ParameterEstimates
Label: Parameter Estimates
Template: Stat.REG.ParameterEstimates
Path: Reg.MODEL1.Fit.y.ParameterEstimates
-------------

Wednesday, July 15, 2009

Statistics: What statistical analysis should I use?

http://www.ats.ucla.edu/stat/mult_pkg/whatstat/default.htm

Friday, July 10, 2009

Statistics: TURF Analysis

TURF Analysis, an acronym for "Total Unduplicated Reach and Frequency", is a type of statistical analysis used for providing estimates of media or market potential and devising optimal ways how to use it given the limited resources.

TURF is a statistical model that can used to answer questions like :
1) Where should we place ads to reach the widest possible audience?
2) What kind of market-share will we gain if we add a new line to our model?

http://en.wikipedia.org/wiki/TURF_Analysis
http://www.questionpro.com/akira/showArticle.do?articleID=turf01

Excel VBA: Loops Syntax

Sub ForLoop()
Dim I As Long

For I = 1 To 5 Step 1
MsgBox I
Next I

For I = 5 To 1 Step -1
MsgBox I
Next I

End Sub
---------------------------------



Sub DoLoop1()

Dim I As Long

I = 0
Do While I < 0
MsgBox I
I = I + 1
Loop

End Sub
---------------------------------



Sub DoLoop2()

Dim I As Long

I = 0
Do
MsgBox I
I = I + 1
Loop While I < 0

End Sub

---------------------------------


Sub DoLoop3()
Dim I As Long

I = 0
Do Until I > 5
MsgBox I
I = I + 1
Loop

End Sub

---------------------------------


Sub DoLoop4()
Dim I As Long

I = 0
Do
MsgBox I
I = I + 1
Loop Until I > 5

End Sub

Excel VBA: Search And Replace in different files

Sub SearchAndReplace()
Dim oFSO As New FileSystemObject
Dim oFileIn As TextStream
Dim oFileOut As TextStream
Dim sLine As String

If Not oFSO.FileExists("C:\Test\Try04.txt") Then
MsgBox "File Not Found", vbCritical
Exit Sub
End If

Set oFileIn = oFSO.OpenTextFile("C:\Test\Try04.txt")
Set oFileOut = oFSO.CreateTextFile("C:\Test\Try05.txt")

Do While Not oFileIn.AtEndOfStream
sLine = oFileIn.ReadLine
sLine = Replace(sLine, "4", "X")

'sLine = Replace(oFileIn.ReadLine, "4", "X")

oFileOut.WriteLine sLine

Loop
oFileIn.Close
oFileOut.Close

Set oFileIn = Nothing
Set oFileOut = Nothing
Set oFSO = Nothing

MsgBox "Over", vbInformation
End Sub