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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

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