This was originally posted by Morague in the SimPE Forum, I have just expanded on it and added pics, for those that need a visual guide.
I have posted this on an adult site, so for those that don't frequent those sites, here it is.
You will need SimPE.
First we need to find the Character File.
Under 'Tools', hover your mouse over 'Neigborhood', a sub menu will show, in that click 'Neighborhood Browser'.
When it opens, click on the Hood the sim you want to change is in and then click 'Open'. It will take a while, don't touch anything, just wait. Keep an eye on the SimPE border at the bottom left of the screen as you will see 'please wait' and a building of the data base needed.
Back up to Tools', hover your mouse over 'Neigborhood', a sub menu will show, in that click 'Sim Browser'.
When it opens, put a tick in 'playable' only.
Now this what we need to change gender, so find the name of the Sim and write down the Filename, In my case it is N005_User00977, if you have others, write down their Filenames as well.
Once you have the Filenames, close the Sim Browser Window by clicking the red cross in the top right hand corner of that window.
Up to 'File', in the Menu click 'Close'.
Now to change the Gender of the Sim.
Up to File and click 'Open'.
Open that Character file in SimPe - the Character files are located in the My Documents/EA Games/Sims 2/Neighborhood/N00?/Characters folder. The ? needs to be replaced by the number in your Filename, in my case 5 from N005. Find the Filename and then click open.
Click 'Catalogue Description' and make sure you have the right Filename'. Make sure you click 'Plugin View' in the bottom pane, so you can see the details.
Now click 'Age Data'.
Now in the Plugin View' click 'Gender'.
Now on the right hand side of the 'Plugin View', you need to change the 'Value' to what you want. Make sure to click 'Commit' after the change.
0x00000001 is female & 0x00000002 is male
Now click on 'Property Set', there will be quite a few depending on the number of Ep's you have. You have to click on every one of those and change the 'Gender' as in the 'Age Data' screens above.Important. When you have finished the changes, go up to 'File' in the Menu click 'Save'.
Up to 'Tools', 'Neighborhood' open your Hood with 'Neighborhood Browser', after it has opened, up to 'Tools', 'Neighborhood' this time 'Sim Surgery', find the Sim you have changed, click 'Use' and then close the Window ny clicking the red cross.
In the 'Plugin View' with Overview showing, change the 'Treat as' to either male or female depending what you did earlier.Important. When you have finished the changes, go up to 'File' in the Menu click 'Save'.
That is all you have to do with SimPE, so you can close it.
The only thing left is to go into game, if the Sim was a baby or child the changes won't take effect until they age up, for Teen and above just go to a mirror and click 'Change Appearance', click 'OK' your Sim has changed gender.
Just to show Daniel Pleasant on entering the lot, after his gender change.
After going to the mirror, a name change might be in order.