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
Maxim 1: Read the Documentation.
Maybe you were thinking of the LOWCASE function.
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.
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>;"
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.
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.