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

I want to create a data set as shown below:

data set.png

I used the following (column input) code:

data GYM_UPDATE;
    infile datalines pad;
    input @1 ID @3 Gender $ Age 5-6 Vault 8-10 Floor 12-14 P_BAR 16-18;
    datalines;
3 6.7
5 15 8.1 7.2
7 F
;
run;

The output is strange: 

wrongdataset.png

 

I am able to create the correct data set by using the listing input with comma as the delimiter. However, I still want to figure out what goes wrong in the above column input code. Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

You miss gender length - how many characters to input.

Try next code:

 

data GYM_UPDATE;
    infile datalines pad;
    input @1 ID @3 Gender $1. 
                  Age 5-6 Vault 8-10 Floor 12-14 P_BAR 16-18;
    datalines;
3              6.7
5   15 8.1 7.2
7 F
;
run;

View solution in original post

2 REPLIES 2
Shmuel
Garnet | Level 18

You miss gender length - how many characters to input.

Try next code:

 

data GYM_UPDATE;
    infile datalines pad;
    input @1 ID @3 Gender $1. 
                  Age 5-6 Vault 8-10 Floor 12-14 P_BAR 16-18;
    datalines;
3              6.7
5   15 8.1 7.2
7 F
;
run;
Zhanxiong
Obsidian | Level 7

It works, thank you so much!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 346 views
  • 1 like
  • 2 in conversation