BookmarkSubscribeRSS Feed
zhawasli1
Obsidian | Level 7

How do I format an old sas program that has one column of a list of different variables that need sorting. Especially if the variables have a period in their names?  I hope you understood.  Thank you.  

7 REPLIES 7
zhawasli1
Obsidian | Level 7
the question goes for finding a confidence interval for these variables that are categorical variables and when i did proc contents there was only one variable listed instead of the five different variables that are in the old sas program. So I need to resort the program so it shows that there are five different variables instead of one and need an analysis of that data after its been manipulated. I think I know how to do the analysis part but I'm having trouble with formatting the old information.
zhawasli1
Obsidian | Level 7

the question goes for finding a confidence interval for these variables that are categorical variables and when i did proc contents there was only one variable listed instead of the five different variables that are in the old sas program. So I need to resort the program so it shows that there are five different variables instead of one and need an analysis of that data after its been manipulated. I think I know how to do the analysis part but I'm having trouble with formatting the old information.

ballardw
Super User

Show the program.

 

Variables typically do not have periods in their names. That would require creating variables with the System option VALIDVARNAME set to ANY and would require referencing them as name literals such as 'stupid.variablename'n

Tom
Super User Tom
Super User

You posted a screenshot of something that seems to be showing a variable named TYPE.  Type looks like it is a character variable with values that contain periods.

 

Do you have a quesiton?

zhawasli1
Obsidian | Level 7
Yes, in this sas program under the proc contents it says one variable, There are actually 206 observations with 5 different variables written in the same column. How do I tell SAS that I need it to pick out each variable and count how many observations are for each variable?? Thanks
Tom
Super User Tom
Super User

You seem to be having a lot of trouble explaining what you want. It does not help that you appear to be using two different definitions of the word variable at the same time.  In SAS a dataset has one or more variables.  The dataset can have multiple observations.  Each observation in the dataset has one value for each of the variables.

 

Perhaps you are asking how to parse a string into multiple values?  If you have variable with values like 

B1.1.2
B2.2.3

And you want to split those at the periods then use the SCAN() function.

data want;
   set have;
   length new1-new3 $10;
   new1=scan(type,1,'.');
   new2=scan(type,2,'.');
   new3=scan(type,3,'.');
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 479 views
  • 1 like
  • 3 in conversation