BookmarkSubscribeRSS Feed
Anandkvn
Lapis Lazuli | Level 10
data cls;
attrib name $upcase.   Sex $lowcase. ;
/* format name $upcase.  sex $lowcase.; */
set sashelp.class;
run;

i want to try name in upcase and sex in lowcase using attrib and format statements 

pls where i did wrong above code

4 REPLIES 4
PeterClemmensen
Super User

You need to specify the Format Attribute the in the Attrib Statement.

 

Also, I don't think a Lowcase Format exists.

 

data cls;
attrib name format = $upcase.;
set sashelp.class;
run;

 

PaigeMiller
Diamond | Level 26

Maybe you were thinking of the LOWCASE function.

 

gender=lowcase(sex);

 

But agreeing with @Kurt_Bremser, you really should check the documentation on these types of questions before coming here, you will save yourself time in the long run. Help documentation is available by pressing F1 in SAS, or via the Internet. I have published this information before, and I provide it again.

 

Alphabetical list of all SAS PROCs

Alphabetical list of all SAS functions

Alphabetical list of all SAS statements

Alphabetical list of all SAS formats

Alphabetical list of all SAS informats

--
Paige Miller
ballardw
Super User

Might want to look at Proc Datasets and the MODIFY statement to change things like formats, labels or variable names in place. When you use a data step then every record is processed and might result in lots of not needed clock cycles. Proc Datasets modifies the data set in place by changing the data set header information.

Use of Proc Datasets is also less likely to accidentally add/remove variables or change values.

Consider a minor typo such as forgetting the E at the end of name:

data cls;
attrib nam format=$upcase. ;
/* format name $upcase.  sex $lowcase.; */
set sashelp.class;
run;

This will add a variable named Nam to the data set.

Note: I don't find any reference to a LOWCASE format. There is an Upcase but not Lowcase supplied by SAS.

If your organization has such installed then that's another story.

You would have to remember that just because the format is applied to a value that you still need to use the base value for referencing the value in code such as: "if name='Alice' then <do something>;"

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 164 views
  • 2 likes
  • 5 in conversation