SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Deleting a variable attribute

    Posted Wed November 30, 2022 05:14 PM
    Hi. 

    I need to remove a variable attribute by name.
    Not just the attribute values, but the entire attribute column in variable view.

    I tried

    VARIABLE ATTRIBUTE
        DELETE = my_var_attr.

    which prints

    Warnings
    VARIABLES is required.
    Execution of this command stops.


    Changing to 

    VARIABLE ATTRIBUTE
        VARIABLES = first_var_in_dataset  TO last_var_in_dataset
        DELETE = my_var_attr.

    works.

    How can I delete a variable attribute if I do _not_ know the first and last variable at runtime and hence can not hard code their names?


    #SPSSStatistics


  • 2.  RE: Deleting a variable attribute

    Posted Wed November 30, 2022 05:22 PM
    Variable attributes are, of course, variable specific, so you have to know the variable name that owns the attribute.  You might be able to use file attributes instead.

    Otherwise, you could iterate over the variable index and find the attributes for each variable via spss.GetVarAttributeNames.

    Otherwise, if you have a list of candidate variables, you could capture the output of DISPLAY ATTRIBUTES with OMS and parse through that.

    ------------------------------
    Jon Peck
    ------------------------------



  • 3.  RE: Deleting a variable attribute

    Posted Sun December 04, 2022 05:30 AM
    Yes, these may be ways to go. However, I don't see why these steps should be required. Sure, variable attributes (or rather their values) are variable specific. But I want to delete an entire attribute without a trace, regardless of variable order or variable-specific attribute values. Just as I can „DELETE VARIABLE my_var" in ignorance of case specific variable values or case order. It's a pity I can't, and so far I consider this an unfavorable implementation detail. Are there any logically imperative reasons why it should not be possible to delete the entire attribute column with its values for all variables with (say) "VARIABLE ATTRIBUTE DELETE = my_var_attr."?





  • 4.  RE: Deleting a variable attribute

    Posted Sun December 04, 2022 10:04 AM
    Why not just Submit a command like this.

    variable attribute variables=all delete=fred.

    --





  • 5.  RE: Deleting a variable attribute

    Posted Sun December 04, 2022 11:26 AM
    I thought I had tried this and had found it not working, while it actually works.
    Great, thank you very much!