简体   繁体   English

Excel 2007。如何将名称转换为唯一 ID?

[英]Excel 2007. How can I convert names into unique IDs?

Currently I am forming a dataset in excel.目前我正在excel中形成一个数据集。 With the dataset, I am going to do the panel regression using stata(fixed effect model).使用数据集,我将使用 stata(固定效应模型)进行面板回归。 However, I cannot change people's names into their unique IDs.但是,我无法将人们的姓名更改为他们的唯一 ID。 In my dataset, I have name in column B, and I want to generate a new column A with corresponding numbers to names in column B. Doing manually is not an option for me since the number of data is larger than 1,000.在我的数据集中,我在 B 列中有名称,并且我想生成一个新的 A 列,其编号与 B 列中的名称对应。因为数据数量大于 1,000,所以手动操作不是我的选择。 Two particular problems I encounter are that names are in Korean so the number of characters are mostly the same, and there are same people in different rows.我遇到的两个特殊问题是名字是韩文,所以字符数基本相同,不同行有相同的人。 Is there any method that I could use?有什么方法可以使用吗?

If I understand you question correctly, I would do following.如果我正确理解你的问题,我会做以下。

Step 1: Used the Advanced Filter to filter on unique names步骤 1:使用高级过滤器过滤唯一名称

You can place these results on the same sheet or on a different sheet (as per Scott Craner's comment).您可以将这些结果放在同一张纸或不同的纸上(根据 Scott Craner 的评论)。 Both options are listed below下面列出了两个选项

Filter Names on the same sheet在同一张纸上过滤名称

  • Select all the data in column B, then click Data > Sort & Filter > Advanced.选择 B 列中的所有数据,然后单击数据 > 排序和筛选 > 高级。
  • Select the option to Copy to another location , Select a blank cell in column B location at the very bottom of your worksheet, several rows away from your data (since you won't be able to paste the results to a new sheet), and then select Unique records only .选择Copy to another location选项,在工作表最底部的 B 列位置选择一个空白单元格,距离数据几行(因为您将无法将结果粘贴到新工作表),以及然后选择仅唯一记录 Then Click OK然后点击确定

Filter Names on a different sheet在不同的工作表上过滤名称

  • Add a new sheet and the click Data > Sort & Filter > Advanced.添加新工作表,然后单击数据 > 排序和过滤器 > 高级。
  • Select the option to Copy to another location选择复制到另一个位置的选项
  • Set the "List range" to the column on your dataset sheet containing the names, and Set the "Copy to" range to B1 on your new sheet将“列表范围”设置为包含名称的数据集工作表上的列,并将“复制到”范围设置为新工作表上的 B1
  • Select Unique records only and then Click OK选择仅唯一记录,然后单击确定

This will paste a new range that has all the unique names in your list.这将粘贴一个包含列表中所有唯一名称的新范围。

Step 2: Assign unique IDs to the names in the unique list步骤 2:为唯一列表中的名称分配唯一 ID

  • This can easily be done by entering '1' in the Column C cell next to the first name in the unique list, '2' next to the second name, selecting those two cells, and then clicking the bottom right corner of the selected cells and dragging it down to the bottom of the unique names list通过在唯一列表中第一个名称旁边的 C 列单元格中输入“1”,在第二个名称旁边输入“2”,选择这两个单元格,然后单击所选单元格的右下角,可以轻松完成此操作并将其拖到唯一名称列表的底部

Now you have a range (ie unique names and IDs) that you can use VLOOKUP to populate an ID column in your data set现在您有一个范围(即唯一名称和 ID),您可以使用VLOOKUP填充数据集中的 ID 列

Step 3: Use VLOOKUP to populate IDs for the rows in your dataset步骤 3:使用VLOOKUP为数据集中的行填充 ID

  • For example, If your unique names and ID is in the range B1200:C1500, then you can enter the following formula in the first row of your dataset in column A (what you want to be the column with your unique IDs)例如,如果您的唯一名称和 ID 在 B1200:C1500 范围内,那么您可以在数据集的第一行 A 列中输入以下公式(您希望成为具有唯一 ID 的列)

=VLOOKUP(B2, $B$1200:$C$1500,2,0)

After you drag this formula down your entire dataset, you'll now have the correesponding unique ID for each name.将这个公式拖下整个数据集后,您现在将拥有每个名称对应的唯一 ID。

Step 4: Cleanup第 4 步:清理

  • Copy your column A (should be all VLOOKUP formulas) and paste Values only so you don't have the formulas there anymore复制您的 A 列(应该是所有 VLOOKUP 公式)并仅粘贴值,这样您就不再有公式了
  • Delete the unique data and IDs range at the bottom of sheet (or the new sheet you created to do this)删除工作表底部的唯一数据和 ID 范围(或您为此创建的新工作表)

暂无
暂无

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

相关问题 Excel用户定义的函数不能在Excel 2007中使用ArgumentDescriptions。我正在尝试在“添加”中绕过它 - Excel User-defined functions can't use ArgumentDescriptions in Excel 2007. I'm trying to bypass it in my Add VBA Excel2007。在单元格中创建按钮 - VBA excel 2007. Create Button in cell Excel2007。日期和时间公式搜索 - Excel 2007. Date and time formulas searching 如何在Excel中显示唯一名称? - How can I display unique names in Excel? Excel 2007中的VBA宏。我想在Excel VBA中使用正则表达式将“他”替换为“她”,将“他”替换为“她”,将“他”替换为“她” - VBA macro in Excel 2007. I want to use Regular Expressions in Excel VBA to replace “He” with “She”, “he” with “she”, “Him” with “her” 选择要在Excel 2007中删除的行范围。运行时错误1004? - Select range of rows to delete in Excel 2007. Runtime error 1004? 另一个针对Excel 2007的优化OPTIMIZING宏VBA代码。该代码是一种用于我的数据的转置器 - Another OPTIMIZING macro vba code for excel 2007. the code is a sort of transposer for my data 如何在Access中使用Excel的(2007)趋势功能? - How can I use Excel's (2007) Trend function in Access? 如何在Excel VBA 2007中为表设置变量范围? - How can I set a variable range to a table in excel VBA 2007? 如何在不使用代码的情况下将多行转换为具有唯一ID的多列,请输入MS EXCEL或MS ACCESS - How to convert multiple rows into multiple columns with unique IDs without code IN MS EXCEL OR MS ACCESS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM