I am trying to use case to vars to do the following... any suggested syntax would be greatly appreciated.
This is what have so far; however, the syntax does not work since I have duplicate code values within
the same case_id.
Thank you
Damir
*******************************************************
SORT CASES BY CASE_ID COURT_ORDER_DATEX CODESC.
CASESTOVARS
/ID=CASE_ID
/INDEX = CODE
/GROUPBY = VARIABLE / DROP COURT_ORDER CODE CODE_DESC.
EXECUTE.
CASE_ID COURT_ORDER CODE CODE_DESC
2005MHXXXXX 05-Jan-2005 1 Petition Involumtary Assessment
2005MHXXXXX 24-Jan-2005 6 Order (General)
2005MHXXXXX 04-Feb-2005 4 Order for Involuntary Treatment
2005MHXXXXX 23-Feb-2005 6 Order (General)
2005MHXXXXX 03-Mar-2005 6 Order (General)
WOULD LIKE
CASE_ID CODE_DATE1 CODE_DATE6.1 CODE_DATE4 CODE_DATE6.2 CODE_DATE6.3
2005MHXXXXX 05-Jan-2005 24-Jan-2005 04-Feb-2005 23-Feb-2005 03-Mar-2005
|
Administrator
|
Damir, your post came across as one uninterrupted string in the Nabble archive. Here's what it was meant to look like, I think.
---- I am trying to use case to vars to do the following... any suggested syntax would be greatly appreciated. This is what have so far; however, the syntax does not work since I have duplicate code values within the same case_id. Thank you Damir ******************************************************* SORT CASES BY CASE_ID COURT_ORDER_DATEX CODESC. CASESTOVARS /ID=CASE_ID /INDEX = CODE /GROUPBY = VARIABLE / DROP COURT_ORDER CODE CODE_DESC. EXECUTE. CASE_ID COURT_ORDER CODE CODE_DESC 2005MHXXXXX 05-Jan-2005 1 Petition Involumtary Assessment 2005MHXXXXX 24-Jan-2005 6 Order (General) 2005MHXXXXX 04-Feb-2005 4 Order for Involuntary Treatment 2005MHXXXXX 23-Feb-2005 6 Order (General) 2005MHXXXXX 03-Mar-2005 6 Order (General) WOULD LIKE CASE_ID CODE_DATE1 CODE_DATE6.1 CODE_DATE4 CODE_DATE6.2 CODE_DATE6.3 2005MHXXXXX 05-Jan-2005 24-Jan-2005 04-Feb-2005 23-Feb-2005 03-Mar-2005
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
I would seem obvious that using CODE as the index might be counter productive?
See the archives for how to build a counter using LAG, then use that counter as INDEX.
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?" |
In reply to this post by DKUKEC
You can remake your "code" variable to conform to the new mappings, example below.
*****************************************************************************************************************. data list list (",") / CASE_ID (A20) CODE_DATE (A20) CODE (A3) CODE_DESC (A50). begin data 2005MHXXXXX,05-Jan-2005,1,Petition Involumtary Assessment 2005MHXXXXX,24-Jan-2005,6,Order (General) 2005MHXXXXX,04-Feb-2005,4,Order for Involuntary Treatment 2005MHXXXXX,23-Feb-2005,6,Order (General) 2005MHXXXXX,03-Mar-2005,6,Order (General) end data. dataset name orig. *Make a new code variable that signifies order. string CODE2 (A3). sort cases by CASE_ID CODE CODE_DATE. DO IF $casenum = 1. or CASE_ID <> lag(CASE_ID). compute #id = 1. ELSE IF CASE_ID <> lag(CASE_ID) or CODE <> lag(CODE). compute #id = 1. ELSE IF CASE_ID = lag(CASE_ID) and CODE = lag(CODE). compute #id = lag(#id) + 1. END IF. compute CODE2 = CONCAT(RTRIM(CODE),".",STRING(#id,F1.0)). exe. *Then usual casestovars. SORT CASES by CASE_ID CODE2. CASESTOVARS /ID = CASE_ID /INDEX = CODE2 /SEPERATOR = "_" /GROUPBY=VARIABLE. *****************************************************************************************************************. If you don't want codes that have multiple instances to not be "?.1" you will need to do another step (e.g. AGGREGATE counts) to recode them. |
Thank you Bruce for cleaning up my post. Can this be avoided in the future if I use text rather HTML?
Thank you Andy, your proposed solution worked after a slight modification allowing for two decimals for the CODE2 var. Cheers, Damir |
Administrator
|
"Can this be avoided in the future if I use text rather HTML?"
That's an empirical question. Try it and see what happens! ;-)
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by DKUKEC
Quick run-down for HTML, short answer is yes not clicking "Message is in HTML Format" should save formatting as it is visible in the text editing box on Nabble.
1) There is a button to preview the message, always do this regardless of HTML or not! 2) Paragraphs in HTML are marked by a "<p>" tag, and in xml spec. all tags need a closing tag, so the end of the paragraph would have a "</p>" tag. If you don't have these, the text will run all-together as in your post. 3) Useful extra, I like HTML for long code snippets, this can be accomplished by a "<pre><code>" tag, then copy-paste the whole snippet, then end with a "</code></pre>". I'll leave it to the interested to see what the code and the pre tag do. |
I wonder if the List is somehow randomly fouling up messages that
it relays ... either, in tiny ways, or differently to different readers. The post that Bruce re-wrote was one that looked perfectly fine to me. I'm reading what is sent by SPSS-L, not from Nabble. I'm reading with Firefox, through MSN-Live mail. On the other hand, there was a post from Bruce a couple of days ago that was compressed/ wrapped around in the way that he described. I have seen a few such posts before. Lately, I discovered that I could see them properly formatted if I hit Reply (even though I don't intend to). That also works to reformat some posts that HTML and which first show themselves to me as spread across many extra lines. One thing that further inspires my opening statement is that, just now, I read a post from Ryan that is messed up, mainly by having a whole lot of the letter a -- at the start of lines, and within lines. That looks (I think) like a bad translation of the characters that make borders. "Reply" did nothing to this one. -- Rich Ulrich > Date: Wed, 5 Jun 2013 12:40:55 -0700 > From: [hidden email] > Subject: Re: Case to Vars with incremental vars? > To: [hidden email] > > Quick run-down for HTML, short answer is yes not clicking "Message is in HTML > Format" should save formatting as it is visible in the text editing box on > Nabble. > > 1) There is a button to preview the message, always do this regardless of > HTML or not! > 2) Paragraphs in HTML are marked by a "<p>" tag, and in xml spec. all tags > need a closing tag, so the end of the paragraph would have a "</p>" tag. If > you don't have these, the text will run all-together as in your post. > 3) Useful extra, I like HTML for long code snippets, this can be > accomplished by a "<pre><code>" tag, then copy-paste the whole snippet, then > end with a "</code></pre>". I'll leave it to the interested to see what the > code and the pre tag do. > > > > ----- > Andy W |
Administrator
|
Re Rich's point about Reply, Damir's original compressed post looked fine when I clicked Reply in Nabble.
FWIW, Nabble has a check box for "Message is in HTML Format", but I never check it.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Free forum by Nabble | Edit this page |