delete decimals

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

delete decimals

Postby GerineL » Wed Nov 02, 2011 2:31 pm

how can i set up a format in such a way that there are no decimal points?

here is an example.
I have a variable named SubjectNr.

Entries are like this:
experiment1_s101
experiment1_s102
...
experiment1_s299

I want a new variable called ID which has the following values:
101
102
299

I don't want any decimals.

here's what I did:

String ID_a (a3).
execute.

compute ID_a = substr(Subjectnr,14,3).
execute.

compute ID = number(ID_a,f3.0).
execute.
I thought f3.0 meant: room for 3 numbers, 0 behind the comma.
However, this syntax gives me the following result:

101,00
102,00
...
299,00

How do I get rid of these annoying decimal points?
JonPedersen
Posts: 118
Joined: Wed May 25, 2011 7:07 am
Contact:

Re: delete decimals

Postby JonPedersen » Thu Nov 03, 2011 5:56 am

formats ID (F3.0).

The point is that yes, the F3.0 in your number statement relates to a format, but that format is how your string is interpreted, not how the resulting variable is displayed.
jon
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: delete decimals

Postby GerineL » Thu Nov 03, 2011 8:47 am

aaah, ok, nice thanks.

Who is online

Users browsing this forum: No registered users and 3 guests

cron