BookmarkSubscribeRSS Feed
HM3
Calcite | Level 5 HM3
Calcite | Level 5
data test;
a=2;
b=2;
proc print data=test;
run;
this will give me a=2 b=2.
Now I want to do same for
a=m;
b=a;

and want to get the output a=m b=m.

Can the same done with dates?

how to declare the same?
data test;
a=12/10/2009 --> how to extract the weekday from a?
Pl help.
partha
6 REPLIES 6
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The SAS language has date and datetime functions. Check the DOC - suggested reading link provided below.

Scott Barry
SBBWorks, Inc.

SAS Language Reference: Concepts, About SAS Date, Time, and Datetime Values
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002200738.htm
DPraba79
Calcite | Level 5
> data test;
> a=2;
> b=2;
> proc print data=test;
> run;
> this will give me a=2 b=2.
> Now I want to do same for
> a=m;
> b=a;
>
> and want to get the output a=m b=m.

You have to use quatition mark inorder to assign value to variable.

a='m';
b=a;

> how to declare the same?
> data test;
> a=12/10/2009 --> how to extract the weekday from a?
> Pl help.
> partha

You can use INPUT function like below.

A=INPUT('12/10/2009',MMDDYY10.);
HM3
Calcite | Level 5 HM3
Calcite | Level 5
Thanks.
SASPhile
Quartz | Level 8
Partha,
Are you looking for this:

proc format;
value whatday 1='Sunday'
2='Monday'
3='Tuesday'
4='Wednesday'
5='Thursday'
6='Friday'
7='Saturday';

run;

data test;
a='12/18/2009';
b=input(a,mmddyy10.);
format b mmddyy10.;
c=weekday(b);
format c whatday.;
run;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
If interested, consider a more standard approach using the SAS-supplied DOWNAME format to get the weekday name from a SAS DATE type variable.

Scott Barry
SBBWorks, Inc.
Peter_C
Rhodochrosite | Level 12
HM3
are you talking "constants"?
a=2
assigns a constant to variable A.
"25dec2009"d
is a date constant

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 928 views
  • 0 likes
  • 5 in conversation