Search found 52 matches

Go to advanced search

by 0101
Wed Mar 25, 2015 1:59 am
Forum: Coding SPSS syntax
Topic: Merge data where date in File 1 is between 2 dates in File 2
Replies: 1
Views: 300

Merge data where date in File 1 is between 2 dates in File 2

File 1 (Census) holds child population estimates for every state, for various years. It has variables called State, ChildPopulation, and CensusDate. CensusDate has values like 7/1/2011, 7/1/2011, 7/2/2012, etc. File 2 (MyData) has a lot of data for each State, including two variables, DtStart and Dt...
by 0101
Thu Mar 12, 2015 4:49 pm
Forum: Modifying SPSS output
Topic: Exporting output to Excel 2007 - workbook is empty
Replies: 1
Views: 1463

Exporting output to Excel 2007 - workbook is empty

I'm using SPSS verison 22 and I am using the OUTPUT EXPORT and CREATESHEET commands to output a custom table to an Excel file, using the XLSX extension (i.e., Excel 2007 +). My code ran fine when using the .XLS extension (Excel 2003). But with the XLSX extension, if the workbook doesn't exist, I get...
by 0101
Wed Jan 14, 2015 6:42 pm
Forum: Coding SPSS syntax
Topic: Merge two files with duplicates in both
Replies: 1
Views: 354

Merge two files with duplicates in both

I would like to merge two datasets, but both have duplicate IDs (Metric is the ID I'm matching on) in them. My first dataset has: State Metric Result AL Employment .40 CA Employment .52 AL Poverty .30 CA Poverty .24 ... My second dataset has: Metric UsedFor Employment Forecasting Employment Reportin...
by 0101
Tue Jan 13, 2015 2:49 pm
Forum: Coding SPSS syntax
Topic: Extracting last two digits of user specified value
Replies: 4
Views: 511

Re: Extracting last two digits of user specified value

For example, if the user specifies 2011 for the YYYY macro, my syntax extracts the last two digits and passes it as a string to the YYstr2 macro (e.g., "11"). So far so good. I'd now like to send some output to an Excel workbook and name the Excel worksheet after the value of YYstr2. So, in this exa...
by 0101
Sun Jan 11, 2015 6:45 pm
Forum: Coding SPSS syntax
Topic: Extracting last two digits of user specified value
Replies: 4
Views: 511

Extracting last two digits of user specified value

I have a macro where the user specifies a year, and I use that macro (YYYY) value in subsquent date calculations. e.g.: define YYYY () 2012 !enddefine. I then have another macro where the user specifies the last two digits of the year, as a string. define YYstr () "12" !enddefine. I use the YYstr ma...
by 0101
Tue Jul 08, 2014 7:09 pm
Forum: Coding SPSS syntax
Topic: Use repeat or loop to specify a list of values
Replies: 3
Views: 682

Use repeat or loop to specify a list of values

I have some simple code where the user defines a year of interest, and then a date is calculated based on the year provided. I then save some output with the year appended to the file name: * Define the FFY. define YYYY () 2011 !enddefine. * Run some code. compute FFY = date.mdy(10,01,YYYY-1). * Sav...
by 0101
Wed May 07, 2014 2:41 pm
Forum: Coding SPSS syntax
Topic: simple date macro not working
Replies: 0
Views: 1702

simple date macro not working

I'm trying to use a simple date macro, but when I use the macro in a date function (date.mdy(!EndDate)) I get an error about the the number of arguments supplied. define !EndDate ( ) date.mdy(09,01,2013) !enddefine. compute FlagCase=0. if missing(DOB) and (VisitDate lt date.mdy(!EndDate)) FlagCase=1...
by 0101
Mon Feb 03, 2014 2:53 pm
Forum: Coding SPSS syntax
Topic: Macro to change format of many variables
Replies: 0
Views: 1625

Macro to change format of many variables

I'm using a macro from Raynald's site to convert a list of variables from string to numeric: http://www.spsstools.net/MacroTutorial.htm#Version3 But I noticed, even using the sample data list he provides, the macro ends up *deleting* the variables rather than converting them. His first macro defines...
by 0101
Thu Jan 23, 2014 3:48 pm
Forum: Coding SPSS syntax
Topic: Cases to vars challenge
Replies: 2
Views: 759

Re: Cases to vars challenge

Try this syntax: ... Thank you! I should have mentioned that my real data includes approximately 150 possible values of measure (calories and weight are just two examples). So I'm looking for a more automated solution, which I think would happen here: RENAME VARIABLES VisitDate.1 = HxVisitDate1 Vis...
by 0101
Wed Jan 22, 2014 7:56 pm
Forum: Coding SPSS syntax
Topic: Cases to vars challenge
Replies: 2
Views: 759

Cases to vars challenge

I have data in the following "long" format (attached file): ID Local Age VisitType VisitDate VisitNo Measure Response 1 Yes 5 Hx 01/01/2010 1 weight 200 1 Yes 5 Hx 01/01/2010 1 calories 3500 1 Yes 5 Hx 02/02/2010 2 weight 190 1 Yes 5 Hx 02/02/2010 2 calories 3300 1 Yes 5 Hx 09/15/2010 3 weight 180 1...
by 0101
Thu Aug 01, 2013 9:36 pm
Forum: Statistics for beginners
Topic: Summarizing years working
Replies: 1
Views: 729

Re: Summarizing years working

Anyone?
by 0101
Sun Jul 21, 2013 11:42 pm
Forum: Statistics for beginners
Topic: Summarizing years working
Replies: 1
Views: 729

Summarizing years working

I have data on how many years and months people have worked in their current position. A person who has worked for 7 months has WorkYears = 0 and WorkMonths = 7. A person who has worked for 20 years and 7 months has WorkYears = 20 and WorkMonths = 7. etc. I would like to calculate descriptive stats ...
by 0101
Sat Jun 29, 2013 5:07 am
Forum: Coding SPSS syntax
Topic: Conditional macro - substitute different variable name
Replies: 0
Views: 1786

Conditional macro - substitute different variable name

I have spent a while trying to figure this out. It seems it should be easy. I would like to be able to specify the dataset I'm working with e.g., (compute DataSet = 1), and then conditionally define some macros based on the specified DataSet. Then I can run a bunch of syntax and have it use the appr...
by 0101
Thu Jun 27, 2013 4:03 pm
Forum: Coding SPSS syntax
Topic: Create new string var using value labels from a numeric var
Replies: 0
Views: 1877

Create new string var using value labels from a numeric var

I suspect this would be easy, but couldn't find any syntax online. I would like to recode the numeric variable, statenum , into a new string variable, statetxt , where statetxt = the value labels from statenum. For example: statenum statetxt 1 Alabama 2 Alaska 3 California etc. ( statenum is numeric...

cron