SAS: proc import where get_names is at variable row - excel

I have an excel spreadsheet where the names of columns for my first 5 columns are on the 2nd row, and the name for columns on all the other columns are on the 3rd row.
Data starts for every column at row 4.
How can I load this data efficiently in SAS with the appropriate names?
Thanks!

The fastest way would be to make the change in excel.
A slower way would be:
1) use two different import procedures: one for first 5 columns and another for the rest of the columns. You can do this using the RANGE= option in proc import. now you'll have two data sets in work library.
2) Use a data steps to remove empty rows that are between col headers and first row of data.
3) Then use data step to create a row number variable for each data set (using the statement N= ) and do a one-to-one merge to combine the two.
If anyone knows a faster way, let me know. This is the first that came to mind.

Related

Excel copy function with rotation

I have a spreadsheet with two portions, the first's rows are usernames and columns are data types (availability, ID, email etc), the second's rows are the data types and columns are the usernames. The second's values must be calculated based on what is in corresponding cells in the first. The second isn't simply copied from the first, each cell contains calculation based on multiple columns of the first portion.
I have been asked to keep these as they are currently, as in don't just create new new columns in the first portion or rotate the second.
So my question is: is there a way that I can copy a function across columns in a way that the variable changing by column is the row number not the column number?
I know the thing I'm trying to do makes no sense. Makes no sense to me neither, but this is what I've been asked to do.
Ended up using a whole bunch of INDIRECT(ADDRESS(MATCH, MATCH)) functions to get the values then get the desired values from them into the second portion.
A second table or extra column would've been so much cleaner but hey, to each their own.

Transforming Excel worksheet with multiple table in FME

I need to transform Excel files to ESRI FileGDB using FME.
The problem is that my excel worksheets contains more than one table.
Example: At row 1, I have the attributes of the first table. Row 2 to 4 contains the values.
At row 6 I have the attributes of the second table. 45 next rows are the values.
And the same thing for the third table.
These rows can change. I could have the attributes of the second table at any row.
I think the best solution would be to have a process that split the .xls file in three different files so I can transform them directly into ESRI format.
Is there a transformer that could perform this task or should I code it myself in Python?
PS: This process will be called from a REST Service so I can't do this manually. Also, the columns name will always be the same.
Thanks
FME reads the Excel rows in order, so I would add a Counter transformer after reading the Excel file.
The column names don't change, so you could check at which row (number given by the Counter) the new table begins.
Then is just a matter of filtering the features with a TestFilter.

Combine the multiple Match Values in Excel

I want to combine Multiple Match Values in Excel an illustrative picture
the example is in the picture.
I want to concat the the match values in one cell
thanks in advance
How large is your data source ?
Are you considering VBA ?
If you need something quick and dirty, one way could be to use intermediate columns that will add item if they match a given ID. For example, if you have your data in column A and B, then column C could be based on formula_in_C2 = IF(A2="v1",C1&B2,C1).
Expand the formula on the whole column. The last row will give you what you are after. Create similar columns for the other IDs.

How do I automatically add rows to a table in excel to make data match other table in same sheet

I am currently comparing data from two different sources in an excel spreadsheet. My left table is missing a few entities and because the tables are sorted the same way. I have been simply adding rows to the first table to make the rows match up.
Ill use this image to describe what I need a little better:
Consider these two different tables in the same worksheet. I would like a row to be inserted automatically above ID-5 in the first table to make it align with ID-row 5 in the second table. I would also like to do the same thing for ID row 8.
Is there an automatic process I could evoke in order to add rows until the data matches up?
If the right-hand pair of columns is comprehensive (say starting in C1), you might put, in E1 copied down to suit:
=IFERROR(INDEX(B:B,MATCH(C1,A:A,0)),"")
This does not add or delete any rows but should match the left pair with the right pair. If the right pair is not comprehensive list of IDs then append one ID column to the other and delete duplicates on that column to create a complete list.

Combining Excel sheets/groups of columns by a condition in Excel 2007

Is there a way to combine 2 Excel sheets (or groups of columns inside one Excel sheet) so that the rows in one sheet/group append to the other sheet/group where so that certain columns values match.
To clarify:
Lets say I have 2 sheets - Sheet1 and Sheet2. Sheet1 has the columns A,B,C,D. Sheet2 has columns A,E,F,G. Column A in both sheets contains the same data but differently sorted (it is not sorted in conventional way (alphabetically or numerically)). I need to combine these 2 sheets into one, but they need to be combined so that the values in A column match (if possible the result should be ordered in the same way as the Sheet2).
Ideally, the functionality I'm looking for would need to be like SQL's INNER JOIN command.
I'm using Excel 2007.
Thanks
I think you basically described the VLOOKUP function.
You have your two sheets, now you want to create a list, which extends A,B,C,D to A,B,C,D,E,F,G.
For that, you could just use
Sheet1!E1=VLOOKUP(Sheet1!A1,Sheet2!A:G,5,FALSE)
Sheet1!F1=VLOOKUP(Sheet1!A1,Sheet2!A:G,6,FALSE)
Sheet1!G1=VLOOKUP(Sheet1!A1,Sheet2!A:G,7,FALSE)
If you need to create an extra sheet3 as a result, use this:
Sheet3!A1=Sheet1!A1
Sheet3!B1=VLOOKUP(Sheet3!A1,Sheet1!A:D,2,FALSE)
Sheet3!C1=VLOOKUP(Sheet3!A1,Sheet1!A:D,3,FALSE)
Sheet3!D1=VLOOKUP(Sheet3!A1,Sheet1!A:D,4,FALSE)
Sheet3!E1=VLOOKUP(Sheet3!A1,Sheet2!A:G,5,FALSE)
Sheet3!F1=VLOOKUP(Sheet3!A1,Sheet2!A:G,6,FALSE)
Sheet3!G1=VLOOKUP(Sheet3!A1,Sheet2!A:G,7,FALSE)
Hope this interpretation was correct.
Edit:
By the way, because Excel is not mainly intended to function as a database, this operation is a bit messy, because it does not dynamically scale. At least with the second approach, using a thrid sheet. You will have to copy down A1 at least that far, to match the last used row from Sheet1. And if you should copy it down further, so you won't have to worry about it for a while, you might need to error-proof against the empty cells.

Resources