简体   繁体   English

sas更新元数据中的列顺序

[英]sas update column order in metadata

We are using proc metadata (open metadata interface) to update some metadata from XML. 我们正在使用proc元数据 (开放元数据接口)从XML更新一些元数据。 Using updatemetadata method, how can we achieve the following: 使用updatemetadata方法,我们如何实现以下目标:

  • add a new column to a specific location in the Columns association of a given table with the use of the function="REPLACE" option (by default, the new column will be the first in the association) 使用function =“ REPLACE”选项将新列添加到给定表的Columns关联中的特定位置(默认情况下,新列将是关联中的第一列)

We are using version 9.3. 我们正在使用版本9.3。

Thanks in advance! 提前致谢!

We found a solution: It has to be done in two steps. 我们找到了一个解决方案:必须分两个步骤完成。

In the first step the new column has to be added. 第一步,必须添加新列。 Depending on the function you use, it will be either the first or the last column in the table metadata. 根据您使用的功能,它将是表元数据中的第一列或最后一列。

In the second step you have to use the function="replace" option with updatemetadata, where the columns are in the desired order. 在第二步中,您必须对updatemetadata使用function =“ replace”选项,其中列按所需顺序排列。

Example: 例:

In the first updatemetadata block the field TEST_PCT is added to the HBR.TEST_7 table. 在第一个updatemetadata块中,将字段TEST_PCT添加到HBR.TEST_7表中。 Because it is added with function="replace", it will be the first column of the table and the old columns will be after that. 由于它是使用function =“ replace”添加的,因此它将是表的第一列,而旧列将在此之后。

So a second updatemetadata block is needed with the proper column order, and because at this point all columns are already existing, it will reorder them properly. 因此,需要第二个updatemetadata块并具有正确的列顺序,并且由于此时所有列均已存在,因此它将正确地对其重新排序。

<Multiple_Requests>
<UpdateMetadata>
    <Metadata>
        <PhysicalTable  id="A52YJRW0.B30005KO" name="HBR.TEST_7" MemberType="DATA" PublicType="Table"  desc="Test_1_Notes á, é, í, ó, ö, ő, ü, ű" sastablename="TEST_7" UsageVersion="1000000">
            <Columns function="replace">
                <Column  objref="A52YJRW0.B80008J0">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J1">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J2">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J3">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  id="$o601" name="TEST_PCT" desc=" " isnullable="1" PublicType="Column" sascolumnlength="8" sascolumnname="TEST_PCT" SASColumnType="N" SASFormat="COMMAX22.2" SASInformat="COMMAX22.2" UsageVersion="1000000">
                    <Notes>
                        <TextStore Name="PrivateNote"  storedtext=" " TextRole="Note" UsageVersion="0"/>
                    </Notes>
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J5">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J6">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J7">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J8">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J9">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
            </Columns>
        </PhysicalTable>
    </Metadata>
    <Reposid>A0000001.A52YJRW0</Reposid>
    <Type>PhysicalTable</Type>
    <Objects/>
    <NS>SAS</NS>
    <Flags>268435456</Flags>
</UpdateMetadata>
<UpdateMetadata>
    <Metadata>
        <PhysicalTable  id="A52YJRW0.B30005KO" name="HBR.TEST_7" UsageVersion="1000000">
            <Columns function="replace">
                <Column  objref="A52YJRW0.B80008J0">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J1">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J2">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J3">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="$o601">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J5">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J6">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J7">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J8">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
                <Column  objref="A52YJRW0.B80008J9">
                    <Table>
                        <PhysicalTable  objref="A52YJRW0.B30005KO"/>
                    </Table>
                </Column>
            </Columns>
        </PhysicalTable>
    </Metadata>
    <Reposid>A0000001.A52YJRW0</Reposid>
    <Type>PhysicalTable</Type>
    <Objects/>
    <NS>SAS</NS>
    <Flags>268435456</Flags>
</UpdateMetadata>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM