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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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