RE: restructuring-many records into one

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

RE: restructuring-many records into one

prasad
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

RE: restructuring-many records into one

David Marso
Administrator
What should the final file look like?
If you want all diagXX to be in a single line with mastend as the case I would suggest going from multivariable to single variable (VARSTOCASES) followed by CASESTOVARS.  Otherwise you have additional pain.
What do you wish to determine from the final restructured data?
Better to have an upload of the actual anonymized data than a screenshot.
prasad wrote
Hi David,

Apologies for not furnishing the full information.

1.      There are diag20 in the file

2.      I built and index with a view to use it, but had trouble populating the vector.

3.      CASESTOVARS will be tried.

I have attached a screenshot of the data file (var are shown only till 13).

Your input will be much appreciated.

Thanks
Prasad

From: David Marso [via SPSSX Discussion] [mailto:[hidden email]]
Sent: Friday, 12 October 2012 10:33 a.m.
To: Prasad Nishtala
Subject: Re: restructring-many records into one

What do you expect this to do?
Maybe you should look at CASESTOVARS instead of trying to run code which it appears you do not understand.
eg VECTOR X=diag01 to diag20.
You only have up to diag06 in your data file
and you build an index? tasknum
but don't use it to populate the vector.
--
prasad wrote
How to convert this:
    mast_enc     ENDTYPE   FUND diag01     diag0 diag03 diag04 diag05 diag06
..0.GVcV2Xk     DR       N          E1120  N1891  D638    E1170  H350    Z8643
..0.GVcV2Xk     DR       N          E1120  N1891  D638    E1170  I500     H350    J22
..0.GVcV2Xk     DR       N          K529


To
..0.GVcV2Xk     DR       N          E1120  N1891  D638    E1170  H350    Z8643  1500 J22 K529

i tried this, but it only pickups the first record.

COMPUTE tasknum=1.
DO IF ($CASENUM NE 1).
IF (MAST_ENC EQ LAG(MAST_ENC)) tasknum = LAG(tasknum)+1.
END IF.
VECTOR X=diag01 to diag20.
AGGREGATE
  /OUTFILE=*
  /BREAK=mast_enc
  /diag01 to diag20= max (diag01 to diag 20).
EXECUTE.

your help is invaulable.

prasad
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.

________________________________
If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/restructring-many-records-into-one-tp5715605p5715606.html
To unsubscribe from restructring-many records into one, click here<http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5715605&code=cHJhc2FkLm5pc2h0YWxhQG90YWdvLmFjLm56fDU3MTU2MDV8LTgyMTM2Mjc=>.
NAML<http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>


datafile.png (225K) <http://spssx-discussion.1045642.n5.nabble.com/attachment/5715607/0/datafile.png>
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

RE: restructuring-many records into one

prasad
Thanks David,
Agree, my intention was to have all diag in 1 line with mastend as case 1.
Will VARSTOCASES AND CASESTOVARS work when you have more than 400,000 records.
Point noted. The data is anonymised, but agree supplying a screenshot is not a good idea.
I will be linking it to the prescription data.
Prasad
Reply | Threaded
Open this post in threaded view
|

RE: restructuring-many records into one

David Marso
Administrator
No problemo!
Consider:
input program.
+  numeric id rec (n6.0).
+  string diag01 to diag20 (a8).
+  vector diag=diag01 to diag20.
+  loop id=1 to 100000.
+    compute #nrec=trunc(uniform(20)).
+    loop rec=1 to #nrec.
+      compute #ndiag=trunc(uniform(20)).
+      loop #d=1 to #ndiag.
+        compute #x= trunc(uniform(20)).
+        compute diag(#d)=string(#x,N5).
+      end loop.
+      leave id.
+      end case.
+    end loop.
+  end loop.
+  end file.
end input program.
exe.

VARSTOCASES  /MAKE trans1 FROM diag01 to diag20 /KEEP =  id  /NULL = DROP.
CASESTOVARS /ID = id /GROUPBY = VARIABLE .


prasad wrote
Thanks David,
Agree, my intention was to have all diag in 1 line with mastend as case 1.
Will VARSTOCASES AND CASESTOVARS work when you have more than 400,000 records.
Point noted. The data is anonymised, but agree supplying a screenshot is not a good idea.
I will be linking it to the prescription data.
Prasad
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Automatic reply: restructuring-many records into one

Veena Nambiar

I am currently out of the office and will return your message upon my return on Monday, October 15th. Thanks.

Reply | Threaded
Open this post in threaded view
|

RE: restructuring-many records into one

prasad
In reply to this post by David Marso

Gracias. I will run the syntax and let you know.

Cheers Prasad

 


From: David Marso [via SPSSX Discussion] [ml-node+[hidden email]]
Sent: Friday, 12 October 2012 1:43 PM
To: Prasad Nishtala
Subject: RE: restructuring-many records into one

No problemo!
Consider:
input program.
+  numeric id rec (n6.0).
+  string diag01 to diag20 (a8).
+  vector diag=diag01 to diag20.
+  loop id=1 to 100000.
+    compute #nrec=trunc(uniform(20)).
+    loop rec=1 to #nrec.
+      compute #ndiag=trunc(uniform(20)).
+      loop #d=1 to #ndiag.
+        compute #x= trunc(uniform(20)).
+        compute diag(#d)=string(#x,N5).
+      end loop.
+      leave id.
+      end case.
+    end loop.
+  end loop.
+  end file.
end input program.
exe.

VARSTOCASES  /MAKE trans1 FROM diag01 to diag20 /KEEP =  id  /NULL = DROP.
CASESTOVARS /ID = id /GROUPBY = VARIABLE .


prasad wrote
Thanks David,
Agree, my intention was to have all diag in 1 line with mastend as case 1.
Will VARSTOCASES AND CASESTOVARS work when you have more than 400,000 records.
Point noted. The data is anonymised, but agree supplying a screenshot is not a good idea.
I will be linking it to the prescription data.
Prasad
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/RE-restructuring-many-records-into-one-tp5715607p5715612.html
To unsubscribe from RE: restructuring-many records into one, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

RE: restructuring-many records into one

prasad
In reply to this post by David Marso

thanks david,

varstocases worked!!


From: David Marso [via SPSSX Discussion] [ml-node+[hidden email]]
Sent: Friday, 12 October 2012 1:43 PM
To: Prasad Nishtala
Subject: RE: restructuring-many records into one

No problemo!
Consider:
input program.
+  numeric id rec (n6.0).
+  string diag01 to diag20 (a8).
+  vector diag=diag01 to diag20.
+  loop id=1 to 100000.
+    compute #nrec=trunc(uniform(20)).
+    loop rec=1 to #nrec.
+      compute #ndiag=trunc(uniform(20)).
+      loop #d=1 to #ndiag.
+        compute #x= trunc(uniform(20)).
+        compute diag(#d)=string(#x,N5).
+      end loop.
+      leave id.
+      end case.
+    end loop.
+  end loop.
+  end file.
end input program.
exe.

VARSTOCASES  /MAKE trans1 FROM diag01 to diag20 /KEEP =  id  /NULL = DROP.
CASESTOVARS /ID = id /GROUPBY = VARIABLE .


prasad wrote
Thanks David,
Agree, my intention was to have all diag in 1 line with mastend as case 1.
Will VARSTOCASES AND CASESTOVARS work when you have more than 400,000 records.
Point noted. The data is anonymised, but agree supplying a screenshot is not a good idea.
I will be linking it to the prescription data.
Prasad
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/RE-restructuring-many-records-into-one-tp5715607p5715612.html
To unsubscribe from RE: restructuring-many records into one, click here.
NAML