SPSS, MS-SQL2008 & bigint

March 31st, 2010 by exhuma.twn

There seems to be an issue with SPSS while reading data from an MS-SQL-Server instance. Notably with the SQL datatype “bigint”. Assume the following SPSS syntax:

GET DATA
   /TYPE=ODBC
   /CONNECT='DSN=my_dsn;SERVER=server_name;Trusted_Connection=yes;DATABASE=db_name'
   /SQL = 'SELECT year FROM  my_table'
.
EXECUTE.

If the field in question (in this case: “year”) is of SQL-type “bigint” then SPSS will show these values in the majority of the cases as “MISSING”. Sporadically some values appear, but they are completely wrong.

Once the cause is known (problem with the “biging” type), the solution is straight-forward: Cast the type to another appropriate type which is understood by SPSS. Which type you choose obviously depends on the values stored in the affected fields. Casting blindly to “int” may (I haven’t tested this!) resolve in strange results if the values lie outside of the “int” range (-2^31 to 2^31-1). In this case you may need to cast it to something alphanumeric like “varchar” and re-cast it in SPSS into “Numeric”. As said, I haven’t tested this but I thought it might be worth mentioning!

So, here’s the above query with the appropriate cast:

GET DATA
   /TYPE=ODBC
   /CONNECT='DSN=my_dsn;SERVER=server_name;Trusted_Connection=yes;DATABASE=db_name'
   /SQL = 'SELECT CONVERT(int, year) AS year FROM  my_table'
.
EXECUTE.

Note also that in this case you need to add an alias for the column ( “… AS year” ). Otherwise SPSS will return it as “VXXX” (where XXX is a sequential number).

I have tested this solution on all combinations of SPSS 11.5, SPSS 18, SQL-Server 2008 64bit, SQL-Server 2008 Express 32bit. And casting the value worked every time.

Depending on your use, it may be helpful to create views which do the casting. I have not yet tried this, but I don’t see a reason why it shouldn’t work. Additionally, it might be noteworthy that I have only encountered this problem with “bigint” so far. There may be problems with other types as well. I expect, casting them to something else should work there too.

Posted in Coding Voodoo | No Comments »

Making “File Size View” in Konqueror suck less

March 5th, 2010 by exhuma.twn

I’ve been down that road many times: “What folder takes up the most disk space”. Over the time lots of junk accumulates on one’s disk. So far the following one-liner has been a trusty companion:

$ du -s * | sort -n

Some other tools are available of which I don’t remember the names. But why not use something that integrates well with Konqueror in KDE? Like “FSView” (short for file-size view)? Well, for one thing it’s painfully slow, and what makes things worse it’s utterly unreadble. But what I figured out this afternoon, is that the app actually offers some quite nice settings. The buty of Konqueror integration is that the “plugins” can insert thei own menu-items wherever they like. Which is nice, because they then integrate well with already existing menu options. But on the other hand, if you are used to open menu paths like “Plugins -> MyPlugin -> Settings” or “Edit/Tools -> Options -> Plugins” you won’t find them.

In the case of fs-view, the options are neatly tucked away in the “View” menu. Which actually makes perfect sense. But working too much on Windows-inspired user interfaces twisted my mind too much and I go looking into the non-obvious places out of pure habit 😉

Now, to spice up fsview a bit I made the following changes:

  • In the “Visualisation” sub-menu:
    • Set “Nesting” to “Vertical”
    • Set “Border” Width to 3
    • Disabled both options “Enable Rotation” and “Shading”
  • In the “Stop at Area” sub-menu:
    • Set value to “400”
  • In the “Stop at Depth” sub-menu:
    • Set value to “2”

Both “Stop at …” settings limit the number of times fs-view has to redraw/rearrange the grid. This should speed things up and it becomes more readable. The end result looks something like this:

FSView with customizations

FSView with customizations

In any case, running fs-view on folders with a large number of files can be very slow and make konqueror even unresponsive while it’s running. Be patient. In my opinion, if you want to determine the biggest file/folder as quickly as possible, the “du -s” method (as outlined above) is preferrable.

Posted in Linux | No Comments »

Pages

Recent Posts

Categories

Links


Archives

Meta