Database SAS

Reply
Occasional Contributor
Posts: 7

Database SAS

I have a important work to do.... (Sorry for my English)

Can you give me the processus or why can i do this : I have to create a database with 1000 obervations and with ONLY 4 variables :

(the 4 variables must have Label, format and Length)

Variable 1:

Name: Numero_Police

Format: 7 charactere (always with 0 before the number)

Value: Disctint number equal to the number of the observation (i.e 0000010)

Variable 2:

Name: Date_fin

Format: Date format SAS (like Date9)

Value: Day=1, Month=Number of obervation / 85 (round and the minimum is 1), Years=2012

Variable 3:
Name: Prix_Charge

Format: Numerical variable with 2 decimal

Value: Random number [0.1]*1000

Variable 4:

Name: Province

Format: chain of character

Observation          Values

1 to 200                 Quebec

201 to 400             Ontario

401 to 600             Terre-Neuve

601 to 800             Alberta

801 to 1000           Manitoba

Super Contributor
Posts: 578

Re: Database SAS

data want(drop=i);

format

    Numero_Police z7.

    Date_Fin date9.

    Prix_Charge 6.2

    Province $10.

;

do i = 1 to 1000;

    Numero_Police=i;

    Date_Fin=mdy(max(i/85,1),1,2012);

    Prix_Charge=ranuni(0)*1000;

    if i le 200 then Province='Quebec';

    else if i le 400 then Province='Ontario';

    else if i le 600 then Province='Terre-Neuve';

    else if i le 800 then Province='Alberta';

    else Province='Manitoba';

    output;

end;

run;

Occasional Contributor
Posts: 7

Re: Database SAS

Thank you very much!!

But i create Data Devoir1 (DROP=i);

So normally the Data go in Bibliotheque Work by default... But its not there??

Occasional Contributor
Posts: 7

Re: Database SAS

It is has if nothing was created...!?

Super Contributor
Posts: 578

Re: Database SAS

did it work before you change the dataset name?  If you are using Enterprise Guide, you may need to refresh the library before the dataset will show. 

Occasional Contributor
Posts: 7

Re: Database SAS

Didnt work... it is not created at any place... i try many thing like creating my database on different file or just put the name Devoir1 for creating this one on Work Library... but didnt work...

Super Contributor
Posts: 578

Re: Database SAS

What does the log say?

Occasional Contributor
Posts: 7

Re: Database SAS

Ok thank you its ok!

If i want to create an other database with the first one, but with only the 3 next variables:

1- POURC_AN: Percentage of the year pass between 1er janvier 2012 and DATE_FIN (FORMAT PERCENT with 1 decimale)

2-DATE_FIN2: Values of the DATE_FIN variable (Numerical format AAAAMMJJ)

3-DATE_FIN3: Values of the DATE_FIN variable (caractere chain AAAAMMJJ)

**And if you can, i have to create a database with only the observation of NUMERO_POLICE that contain minimum one time the caractere "1" in the number!!

Thank you for your help!!! Smiley Happy

Super Contributor
Posts: 578

Re: Database SAS

I think you're looking for date format of yymmddn8.

I'm confused about NUMERO_POLICE.  It is a number, not a character.  Do you only want 1,10,11,12,13,14,15,16,17,18,19,21,31,41,51,61,etc.?

Occasional Contributor
Posts: 7

Re: Database SAS

NUMERO_POLICE is just the name of the variable in the 4 variables (in my first question)

NUMERO_POLICE is the variable that contain seven characters with ALWAYS zeros before the number. For my second question, they want another database that contain only the variable NUMERO_POLICE (in my first question) WITH at least one time the character "1" in the number that contain always zeros before the number....

Sorry if its complicated.... =S

Occasional Contributor
Posts: 7

Re: Database SAS

NUMERO_POLICE is just the name of the variable in the 4 variables (in my first question)

NUMERO_POLICE is the variable that contain seven characters with ALWAYS zeros before the number. For my second question, they want another database that contain only the variable NUMERO_POLICE (in my first question) WITH at least one time the character "1" in the number that contain always zeros before the number....

Sorry if its complicated.... =S

Ask a Question
Discussion stats
  • 10 replies
  • 323 views
  • 3 likes
  • 2 in conversation