Labels from variables?

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

Labels from variables?

Robert L

Would it be possible to use the content in one dataset to define labels in another? Here are two small datasets:

 

DATA LIST FREE/nr(F2) sex(F1).

BEGIN DATA

1, 1, 2, 1, 3, 2, 4, 2

END DATA.

DATASET NAME dataset0.

DATA LIST FREE/sex(F1) sex_t(A6).

BEGIN DATA

1 male 2 female

END DATA.

DATASET NAME labels.

 

In “dataset02”, the variable sex is coded with numerical codes, and in the “labels” dataset, the codes are defined. Is it possible to use this second dataset to define the labels for the variable sex in the first set?

 

Robert

 

===================== 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
Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Labels from variables?

John F Hall

Robert

JKP will probably supply a Python solution, but check out command:

APPLY DICTIONARY (Manual p177)

John

 

John F Hall

[Retired academic survey researcher]

IBM-SPSS Academic Author 9900074

 

Email:             [hidden email]

Website:          http://surveyresearch.weebly.com/

SPSS course:   http://surveyresearch.weebly.com/1-survey-analysis-workshop-spss.html

Research:        http://surveyresearch.weebly.com/3-subjective-social-indicators-quality-of-life.html

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Robert Lundqvist
Sent: 12 December 2017 10:19
To: [hidden email]
Subject: Labels from variables?

 

Would it be possible to use the content in one dataset to define labels in another? Here are two small datasets:

 

DATA LIST FREE/nr(F2) sex(F1).

BEGIN DATA

1, 1, 2, 1, 3, 2, 4, 2

END DATA.

DATASET NAME dataset0.

 

DATA LIST FREE/sex(F1) sex_t(A6).

BEGIN DATA

1 male 2 female

END DATA.

DATASET NAME labels.

 

In “dataset02”, the variable sex is coded with numerical codes, and in the “labels” dataset, the codes are defined. Is it possible to use this second dataset to define the labels for the variable sex in the first set?

 

Robert

 

===================== 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

===================== 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: Labels from variables?

Bruce Weaver
Administrator
In reply to this post by Robert L
Hello Robert.  I'm sure something could be done via that so-called "horrible
hack" method:  I.e., use WRITE to write (to disk) a new text file that
contains the command syntax to apply the labels, and then use INSERT to
execute that syntax.  (Jon is shuddering right now.  Even David may be
grimacing--and he invented the HH.)  

What is the context for your question?  Are you trying to import data from
some other package that stores data in one file and meta-data in another?
Just how scalable does the solution need to be?  Does the small example you
provided show the complete extent of it, or is it just the tip of the
iceberg?  Thanks for clarifying.

Bruce



Robert L wrote

> Would it be possible to use the content in one dataset to define labels in
> another? Here are two small datasets:
>
> DATA LIST FREE/nr(F2) sex(F1).
> BEGIN DATA
> 1, 1, 2, 1, 3, 2, 4, 2
> END DATA.
> DATASET NAME dataset0.
> DATA LIST FREE/sex(F1) sex_t(A6).
> BEGIN DATA
> 1 male 2 female
> END DATA.
> DATASET NAME labels.
>
> In "dataset02", the variable sex is coded with numerical codes, and in the
> "labels" dataset, the codes are defined. Is it possible to use this second
> dataset to define the labels for the variable sex in the first set?
>
> Robert
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|

Re: Labels from variables?

David Marso-2
In reply to this post by Robert L
Definitely need more context and estimate of iceberg magnitude.

=====================
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: Labels from variables?

David Marso-2
In reply to this post by Robert L
I don't see how APPLY DICTIONARY applies here.

=====================
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: Labels from variables?

Robert L
In reply to this post by David Marso-2
You are all correct, there is an iceberg ahead. The question is based on the discussion at a conference some I attended weeks ago, a conference hosted by the Swedish National Data Service, a unit working with making research data accessible. One of the topics was FAIR data (see https://www.force11.org/group/fairgroup/fairprinciples), a neat acronym which stands for (F)indable, (A)ccessible, (I)nteroperable and (R)eusable, a discussion which seems to be quite topical in some quarters.

One of the messages was that research data should preferably be stored in a non-proprietary format, and SPSS files did not really count. Instead what is suggested is simply text/csv files. But then you need to store the metadata in other csv files. And this is where I thought there might be a way to 1) store and organize data and metadata in such files; 2) import those files into SPSS and 3) define value labels, variable labels, custom attributes, missing definitions,... by use of the metadata files. So the iceberg lies in the hope that not just value labels but *all* metadata could be set up this way.

It is not anything I need to do right now, but I wouldn't be surprised if the increasing demands for "data management plans" and "accessible data" from both those who fund research and journals sooner or later will make these issues necessary to solve. And it sounds quite reasonable, or what do you all think?

Robert

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Tuesday, December 12, 2017 2:02 PM
To: [hidden email]
Subject: Re: Labels from variables?

Definitely need more context and estimate of iceberg magnitude.

=====================
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

=====================
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
Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Labels from variables?

Jon Peck
In reply to this post by David Marso-2
Check out this extension command...

STATS VALLBLS FROMDATA Extension Command

Create value labels for a set of variables using values of other variables for the labels

STATS VALLBLS FROMDATA
VARIABLES = variables or VARPATTERN = “regular expression
LBLVARS = string variables or LBLPATTERN = “regular expression

/OPTIONS
VARSPERPASS = integer

/OUTPUT
SYNTAX = “file”
EXECUTE=YES** or NO

/HELP

* Required
** Default

STATS VALLBLS FROMDATA /HELP displays this help and does nothing else.

STATS VALLBLS FROMDATA VARIABLES = x1 TO x5
LBLVARS = label.

This command creates value labels for a set of variables using values of other variables for the labels. If x is a variable having values 1,2,3 and xlabel is a variable having values 'a''b''c', value labels for x are created as

1 'a'
2 'b'
3 'c'

On Tue, Dec 12, 2017 at 6:12 AM, David Marso <[hidden email]> wrote:
I don't see how APPLY DICTIONARY applies here.

=====================
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



--
Jon K Peck
[hidden email]

===================== 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: Labels from variables?

PRogman
In reply to this post by Robert L
There is a script at www.spsstools.net
(http://spsstools.net/en/syntax/syntax-index/labels-variable-names-and-format/apply-lab1-as-value-label-to-var1-by-syntax/)
which does a similar thing. I have used it before. Below is the code updated
to use datasets (still uses the HH). It creates the label file from the test
dataset.
I like the extension command better... will come handy in the future.
/PR

* To apply the string values of lab1as value labels to variable var1.
* [hidden email].

* Use windows standard temp folder.
FILE HANDLE fnTemp /NAME='%temp%\temp.$$$'.

* define some sample data.
DATA LIST LIST
/var1(F8) lab1(A8).
BEGIN DATA.
1 one
1 one
2 two
3 three
3 three
END DATA.
DATASET NAME dsTest.

SUMMARIZE
  /TABLES=var1 lab1
  /FORMAT=VALIDLIST NOCASENUM NOTOTAL LIMIT=100
  /TITLE='Case Summaries'
  /MISSING=VARIABLE
  /CELLS=NONE.

* need first to keep only cases with unique value labels.
DATASET DECLARE dsLabels.
AGGREGATE
  OUTFILE = dsLabels
  /BREAK  = var1
  /lab1   = FIRST(lab1) .

* Note: the dimension of lab2 must be 2 characters larger than the dimention
of lab1.
* However the max dimension of lab2 is 60. If dim of lab1 exceeds 58, use
* COMPUTE lab2=CONCAT(quot,SUBSTR(lab1,1,58),quot) instead of line below.

DATASET ACTIVATE dsLabels WINDOW=ASIS.

STRING  lab2(A10).
COMPUTE lab2=CONCAT('"',lab1,'"').

* write a syntax file to assign the labels.
WRITE OUTFILE fnTemp
/"ADD VALUE LABELS var1 " var1 " " lab2 "."
.
EXECUTE.
DATASET CLOSE dsLabels.

* Get original data file then call syntax to define the value labels.
DATASET ACTIVATE dsTest WINDOW=ASIS.

INSERT FILE = fnTemp.
ERASE FILE  = fnTemp.

SUMMARIZE
  /TABLES=var1 lab1
  /FORMAT=VALIDLIST NOCASENUM NOTOTAL LIMIT=100
  /TITLE='Case Summaries'
  /MISSING=VARIABLE
  /CELLS=NONE.




--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: Labels from variables?

Jon Peck
In reply to this post by Robert L
​​
Another possibility is to use the open Triple-S format for the data/metadata.  (http://www.triple-s.org/)  It claims
"The standard for transferring data and variables between survey systems".  I hate it when groups make claims like this.  I don't think that it is heavily used, but it would accommodate most of the Statistics metadata including multiple response data.  There is an extension command, naturally, STATS GET TRIPLES that reads this format, and I believe some other vendors also support it.



On Tue, Dec 12, 2017 at 6:49 AM, Robert Lundqvist <[hidden email]> wrote:
You are all correct, there is an iceberg ahead. The question is based on the discussion at a conference some I attended weeks ago, a conference hosted by the Swedish National Data Service, a unit working with making research data accessible. One of the topics was FAIR data (see https://www.force11.org/group/fairgroup/fairprinciples), a neat acronym which stands for (F)indable, (A)ccessible, (I)nteroperable and (R)eusable, a discussion which seems to be quite topical in some quarters.

One of the messages was that research data should preferably be stored in a non-proprietary format, and SPSS files did not really count. Instead what is suggested is simply text/csv files. But then you need to store the metadata in other csv files. And this is where I thought there might be a way to 1) store and organize data and metadata in such files; 2) import those files into SPSS and 3) define value labels, variable labels, custom attributes, missing definitions,... by use of the metadata files. So the iceberg lies in the hope that not just value labels but *all* metadata could be set up this way.

It is not anything I need to do right now, but I wouldn't be surprised if the increasing demands for "data management plans" and "accessible data" from both those who fund research and journals sooner or later will make these issues necessary to solve. And it sounds quite reasonable, or what do you all think?

Robert

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Tuesday, December 12, 2017 2:02 PM
To: [hidden email]
Subject: Re: Labels from variables?

Definitely need more context and estimate of iceberg magnitude.

=====================
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

=====================
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



--
Jon K Peck
[hidden email]

===================== 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