BookmarkSubscribeRSS Feed
Andrée
Calcite | Level 5

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

10 REPLIES 10
DBailey
Lapis Lazuli | Level 10

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;

Andrée
Calcite | Level 5

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??

Andrée
Calcite | Level 5

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

DBailey
Lapis Lazuli | Level 10

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. 

Andrée
Calcite | Level 5

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...

DBailey
Lapis Lazuli | Level 10

What does the log say?

Andrée
Calcite | Level 5

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

DBailey
Lapis Lazuli | Level 10

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.?

Andrée
Calcite | Level 5

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

Andrée
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 978 views
  • 3 likes
  • 2 in conversation