BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zhawasli1
Obsidian | Level 7

I want to create a SAS dataset which contains two variables AGE and SEX.  There are 26 entries.  How do I program this into SAS.  Sorry I'm a newbie here . lol 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
I updated the post above earlier, you need to update the code.

SAS is expecting CARDS not CARD.

View solution in original post

7 REPLIES 7
Reeza
Super User

@zhawasli1 wrote:

I want to create a SAS dataset which contains two variables AGE and SEX.  

Where is the data coming from? Are you typing it out? From a text file?

 

Assuming you're typing it out, you would create something as follows:

 

data have;
infile cards dlm=',' truncover;
input age sex $;
cards;
24, F
25, M
;;;;
run;

However, the assumption is you're more likely to read from a file or DB and this step isn't very usual in actual work. 

 


@zhawasli1 wrote:

I want to create a SAS dataset which contains two variables AGE and SEX.  There are 26 entries.  How do I program this into SAS.  Sorry I'm a newbie here . lol 


 

zhawasli1
Obsidian | Level 7
no its from my input right now. thank you so much!
zhawasli1
Obsidian | Level 7

It says error on the log window when I press run, No logical assign for filename CARD.  Not completely sure what that means.  

Reeza
Super User

Show the code and log
I think there's a typo in my post (card versus cards) which I'll fix here in a second.


EDIT: Code is fixed and tested, runs fine. 

zhawasli1
Obsidian | Level 7
 
Reeza
Super User
I updated the post above earlier, you need to update the code.

SAS is expecting CARDS not CARD.
Reeza
Super User

@zhawasli1 wrote:
no its from my input right now. thank you so much!

Literally no idea what that means. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1156 views
  • 1 like
  • 2 in conversation