04-03-2012 11:32 PM
I want to write SAS code that can read in csv file every time it is read, number of columns maybe different.
In addition, I need to use different variables to look up different values.
let's say first time I have 3 columns, it's a look up table, use var1 - var2 to look up RF01
next time when I read in the file, it has 5 columns, use var1 - var3 to look up RF01 and RF02
So, given this situation, the column number is not fixed, and also look up column value is different too.
04-04-2012 04:52 AM
One Clarification.Var1-Var2 are two variables whcihis being used to lookup RF01. when file has 5 columns , we need to use four vairbales to look up.
Any example to explain this would be helpful
04-04-2012 10:23 AM
1st time, table is like this:
var1 var2 RF01
us fin IR
eu tech FX
ca svc sprd
2nd time, table is like this
var1 var2 var3 RF01 RF02
us fin swp crv01 FX
eu corp sptn crv02 sprd
gb bnk edotn crv04 ir
04-06-2012 07:24 AM
Why not use proc import to import csv file.
but about your querying. I don't know which criterion you used to judge variable should be var: or RF: ?
04-06-2012 10:38 AM
Will different iterations of this process also add any rows to your data?
I think the PROC IMPORT solution Ksharp mentioned is a good start but if you have rows added to your data there may be an issue with a variable column changing data types from numeric to string based on the content.
Suppose the first time you read the data with column 10 the values are numeric. Then in a later version added rows in column 10 now contain some text values. Proc import is likely to make that variable string.