Difference

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

Difference

DEBOER
Hi,

Help needed.

Ex.

product     sales   Z
X              10      .
X              20      10
X              15      -5
Y              20      .
Y              50      30
Y              10      -40

to calculate the differences in sales per product (Z) I use the Create command.

sort case product.
split file product.
create Z=diff(sales,1).
exe.

Ok so long so good, my question is how to calculate the above ex in dates recieving days.


Question.

product        date               days
X              10-jan-2011      .
X              20-jan-2011     10
X              15-feb-2011     26
Y              20-mar-2011    .
Y              30-apr-2011     10
Y              10-maj-2011     10


how can I calculate the diff of days?
Reply | Threaded
Open this post in threaded view
|

Re: Difference

Bruce Weaver
Administrator
If I follow, something like this (untested) will do it.  I assume the records are already sorted by PRODUCT and DATE.

IF ($casenum GT 1) and (product NE LAG(product))
  days = datediff(date, LAG(date), "days").



DEBOER wrote
Hi,

Help needed.

Ex.

product     sales   Z
X              10      .
X              20      10
X              15      -5
Y              20      .
Y              50      30
Y              10      -40

to calculate the differences in sales per product (Z) I use the Create command.

sort case product.
split file product.
create Z=diff(sales,1).
exe.

Ok so long so good, my question is how to calculate the above ex in dates recieving days.


Question.

product        date               days
X              10-jan-2011      .
X              20-jan-2011     10
X              15-feb-2011     26
Y              20-mar-2011    .
Y              30-apr-2011     10
Y              10-maj-2011     10


how can I calculate the diff of days?
--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: Difference

David Marso
Administrator
In reply to this post by DEBOER
sort case product.
split file product.
create D_Date=diff(date,1) /D_Sales=diff(sales,1).
COMPUTE D_Date=CTIME.DAYS(D_date).
exe.

DEBOER wrote
Hi,

Help needed.

Ex.

product     sales   Z
X              10      .
X              20      10
X              15      -5
Y              20      .
Y              50      30
Y              10      -40

to calculate the differences in sales per product (Z) I use the Create command.

sort case product.
split file product.
create Z=diff(sales,1).
exe.

Ok so long so good, my question is how to calculate the above ex in dates recieving days.


Question.

product        date               days
X              10-jan-2011      .
X              20-jan-2011     10
X              15-feb-2011     26
Y              20-mar-2011    .
Y              30-apr-2011     10
Y              10-maj-2011     10


how can I calculate the diff of days?
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: Difference

Spousta Jan
In reply to this post by DEBOER
Hi,

Add a new line

compute z = z / 86400.

before exe.

Best,

Jan


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of DEBOER
Sent: Sunday, November 20, 2011 1:25 PM
To: [hidden email]
Subject: Difference

Hi,

Help needed.

Ex.

product     sales   Z
X              10      .
X              20      10
X              15      -5
Y              20      .
Y              50      30
Y              10      -40

to calculate the differences in sales per product (Z) I use the Create command.

sort case product.
split file product.
create Z=diff(sales,1).
exe.

Ok so long so good, my question is how to calculate the above ex in dates recieving days.


Question.

product        date               days
X              10-jan-2011      .
X              20-jan-2011     10
X              15-feb-2011     26
Y              20-mar-2011    .
Y              30-apr-2011     10
Y              10-maj-2011     10


how can I calculate the diff of days?

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Difference-tp5008105p5008105.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD



_____________
Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu.


This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

Are you sure that you really need a print version of this message and/or its attachments? Think about nature.

-.- --

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Difference

DEBOER
In reply to this post by David Marso
Hi all,

Thanks for your reply, David M solutions works perfectly
sort case product.
split file product.
create D_Date=diff(date,1) /D_Sales=diff(sales,1).
COMPUTE D_Date=CTIME.DAYS(D_date).
exe.

Thanks