DATA Step, Macro, Functions and more

Apply the same format to mutiple variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Apply the same format to mutiple variables

[ Edited ]

Dear all, Suppose I've the following code.

PROC FORMAT;
   VALUE $RESP

     '1'="STRONGLY AGREE"

     '2'="AGREE"

     '3'="NEUTRAL"

     '4'="DISAGREE" 

     '5'="STRONGLY DISAGREE" ;

 RUN;

 

DATA SURVEY;

 INFILE DATALINES;

 INPUT ID $ (QUES1-QUES5)($1.);

 

 DATALINES;

 001 52344

 002 53241

 003 43255

 004 55412

 005 32514 ;

 RUN;

 

How do I use the FORMAT statement in the DATA STEP for Ques1 to Ques5?

Regards Dennis K


Accepted Solutions
Solution
‎03-13-2018 02:40 AM
Trusted Advisor
Posts: 1,848

Re: Apply the same format to mutiple variables

just add a line to your code:

 

DATA SURVEY;

 INFILE DATALINES;

 INPUT ID $ (QUES1-QUES5)($1.);

FORMAT ques1-ques5 $resp.  ;  /* or $resp20. assuminc max description is 20 chars */

View solution in original post


All Replies
Solution
‎03-13-2018 02:40 AM
Trusted Advisor
Posts: 1,848

Re: Apply the same format to mutiple variables

just add a line to your code:

 

DATA SURVEY;

 INFILE DATALINES;

 INPUT ID $ (QUES1-QUES5)($1.);

FORMAT ques1-ques5 $resp.  ;  /* or $resp20. assuminc max description is 20 chars */

Occasional Contributor
Posts: 13

Re: Apply the same format to mutiple variables

Dear Shmuel,
Thanks for the help. I'm keeping thinking that i should use the OF statement e.g (of Ques1-Ques5).
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 83 views
  • 0 likes
  • 2 in conversation