LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 14 Nov 2008 01:33:36 -0800
Reply-To:     fomcl@yahoo.com
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Albert-jan Roskam <fomcl@yahoo.com>
Subject:      Re: Auto saving data
Comments: To: "Peck, Jon" <peck@spss.com>
In-Reply-To:  <5CFEFDB5226CB54CBB4328B9563A12EE0A23B6F9@hqemail2.spss.com>
Content-Type: text/plain; charset=us-ascii

Hi,

Below is a simple script that works with FILE HANDLES. You can choose to write a given file to a directory that indicates the month (ie., 11 for november). Alternatively, you can time-stamp the file name (in ISO format) in addition to using a month dir. You just need to specify the base_dir and root_fn to your needs. Just run the entire syntax to see what happens.

Cheers!! Albert-Jan

begin program. import spss, time, os base_dir = "d:/temp" root_fn = "rootname" ymd = str(time.localtime()[0]) + str(time.localtime()[1]) + str(time.localtime()[2]) m_path = base_dir + "/" + str(time.localtime()[1]) try: if not os.path.exists(m_path): os.mkdir(m_path) print "*** m_path: %s" % m_path print "*** ymd: %s" % ymd spss.Submit("FILE HANDLE mydir / NAME = '%s'." % (m_path)) spss.Submit("FILE HANDLE myfile / NAME = '%s/%s_%s.sav'." % (m_path, root_fn, ymd)) spss.Submit("SHOW HANDLES.") except: raise Exception("** Directory already exists!") end program.

get file = 'c:/program files/spss/employee data.sav'. save outfile = myfile. save outfile = 'mydir/somename.sav'.

--- On Fri, 11/14/08, Peck, Jon <peck@spss.com> wrote:

> From: Peck, Jon <peck@spss.com> > Subject: Re: Auto saving data > To: SPSSX-L@LISTSERV.UGA.EDU > Date: Friday, November 14, 2008, 4:29 AM > The easiest way to do this is to specify the paths with a > file handle. Then you only need to redefine the directory > for that handle, and the rest of the job will refer to the > new location. > > FILE HANDLE was enhanced a few releases ago - after 12.0, I > think, but the older version should suffice for your needs. > > HTH, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] > On Behalf Of Thien Hop > Sent: Thursday, November 13, 2008 7:38 PM > To: SPSSX-L@LISTSERV.UGA.EDU > Subject: [SPSSX-L] Auto saving data > > Hi listers, > > I have a question that sounds to be simple but I really > cannot figure out: > how to write a syntax that can autosave the working data > file to its > current location without specifying the path. The files > have already been > named. > > I use version v12 to run monthly stuff, I normally copy the > files to a new > month's folder & manually change the file names > then run some update on the > data...It is troublesome to change the path in the syntax > every time. If > forget to do so, it overwrites the previous month data. > > Any input is much appreciated! > > Hop > > > > > ----- Original Message ----- > From: "Ariel Barak" > <abarakabarak@gmail.com> > To: <SPSSX-L@LISTSERV.UGA.EDU> > Sent: Wednesday, November 12, 2008 11:34 AM > Subject: Re: cases to vars > > > > Hi Keval, > > > > The syntax below is tested and works. The first SORT > CASES command is > > important because it sorts the majors with the primary > majors first before > > restructuring the data. If there were multiple primary > majors, they would > > be > > ordered alphabetically from left to right i.e. Major.1 > Anatomy, Major.2 > > Chemistry, Major.3 Humanities etc. I also included the > possibility of a BS > > degree. > > > > Take it easy, > > Ari > > > > > > > > DATA LIST LIST /ID (F8) Major (A12) DegreeType (A5) > Primary (A1). > > BEGIN DATA > > 1 BIOLOGY BA Y > > 1 CHEMISTRY MINOR N > > 2 POLISCI BA Y > > 3 MATH BA Y > > 3 STATISTICS CONC N > > 4 HISTORY BA Y > > 4 HUMANITIES BA N > > 5 ANATOMY BA Y > > 5 CHEMISTRY BA N > > 5 BIOLOGY BA N > > END DATA. > > > > DATASET NAME Original. > > ************************************************. > > DATASET COPY Major. > > DATASET ACTIVATE Major. > > > > SELECT IF ANY(DegreeTYPE,'BA','BS'). > > EXE. > > > > SORT CASES BY ID (A) Primary (D) Major (A). > > CASESTOVARS > > /ID=ID > > /GROUPBY=VARIABLE. > > ************************************************. > > DATASET ACTIVATE Original. > > > > DATASET COPY Minor_Concentration. > > DATASET ACTIVATE Minor_Concentration. > > > > SELECT IF > (NOT(ANY(DegreeTYPE,'BA','BS'))). > > EXE. > > > > DELETE VARIABLE Primary. > > > > STRING MINOR (A12) CONC (A12). > > IF DegreeType='MINOR' MINOR=Major. > > IF DegreeType='CONC' CONC=Major. > > EXE. > > > > DELETE VARIABLES Major DegreeType. > > ************************************************. > > DATASET ACTIVATE Major. > > > > MATCH FILES /FILE=* > > /TABLE='Minor_Concentration' > > /BY ID. > > EXECUTE. > > > > DATASET CLOSE ALL. > > DATASET NAME Final. > > ************************************************. > > > > On Tue, Nov 11, 2008 at 5:18 PM, Keval Khichadia > > <kkhichadia@yahoo.com>wrote: > > > >> Hi all, > >> > >> I would like to have the dataset below (1) look > like dataset (2). > >> > >> (1) > >> > >> ID MAJOR > DEGREETYPE PRIMARY > >> > >> 1 BIOLOGY > >> BA Y > >> 1 CHEMISTRY MINOR > N > >> 2 POLI SCI > BA > >> Y > >> 3 MATH > BA > >> Y > >> > >> 3 STATISTICS CONC > >> N > >> 4 HISTORY > >> BA Y > >> 4 HUMANITIES BA > >> N > >> 5 ANATOMY BA > >> Y > >> 5 > >> CHEMISTRY BA > N > >> 5 BIOLOGY > >> BA N > >> > >> > >> > >> (2) > >> > >> ID MAJOR1 MAJOR2 MAJOR3 > MAJOR4 > >> MINOR > >> CONCENTRATION > >> > >> 1 BIOLOGY > >> CHEMISTRY > >> 2 POLI SCI > >> > >> 3 MATH > >> STATISTICS > >> 4 HISTORY HUMANITIES > >> 5 ANATOMY CHEMISTRY BIOLOGY > >> > >> > >> If Primary = 'Y' then that major should > always belong in Major1. If the > >> degreetype is Conc that major should always go > into concentration. If the > >> degreetype is minor that major should always go > into Minor. If degreetype > >> is > >> not conc and primary = N, then the majors should > go in order, Major 2, > >> Major > >> 3, Major 4. Sorry, if not clear, the example above > is probably better to > >> look at. > >> > >> > >> Thanks, > >> > >> Keval > >> > >> > >> > >> > >> To manage your subscription to SPSSX-L, send a > message to > >> LISTSERV@LISTSERV.UGA.EDU (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 > >> > > > > ===================== > > To manage your subscription to SPSSX-L, send a message > to > > LISTSERV@LISTSERV.UGA.EDU (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 > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@LISTSERV.UGA.EDU (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 > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@LISTSERV.UGA.EDU (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

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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


Back to: Top of message | Previous page | Main SPSSX-L page